-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DateTimeIndex error when tsmode=True #1631
Comments
Updates:
|
Hi @lpeti69 , can you please share the python version that you are using along with other packages and versions that you have installed? |
I am having the same problem. Python version: 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:12:24) [GCC 11.2.0]
pandas version: 2.2.2
ydata_profiling version: 0.0.dev0 from ucimlrepo import fetch_ucirepo
import pandas as pd
from ydata_profiling import ProfileReport
# fetch dataset
data = fetch_ucirepo(id=374)
# Convert the data to a pandas DataFrame
df = pd.DataFrame(data=data.data.features)
re_express = r'(\d{4})-(\d{2})-(\d{2})(\d{2}):(\d{2}):(\d{2})'
# Replace using the pattern
df['date'] = df['date'].str.replace(re_express, r'\1-\2-\3 \4:\5:\6', regex=True)
# Convert the 'date' column to datetime format
df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d %H:%M:%S', errors='raise')
# df['date_'] = pd.date_range(start='2016-01-11 17:00:00', end='2016-05-27 18:00:00', freq='10min')
# If the data has target labels, you can also add them to the DataFrame
df['target'] = data.data.targets
# # Set the 'date' column as the index
df.set_index('date', inplace=True)
# # Optionally, sort the DataFrame by the new datetime index
df.sort_index(inplace=True)
# Display the first few rows of the DataFrame
# df.head()
profile = ProfileReport(df, tsmode=True, title="Pandas Profiling Report")
profile.to_file("report.html")
# profile.to_notebook_iframe() Summarize dataset: 100% [-------] 821/821 [04:13<00:00, 3.02it/s, Completed]
Generate report structure: 0% [------------] 0/1 [02:08<?, ?it/s]
{
"name": "ValueError",
"message": "Date ordinal 24208860.0 converts to 68251-08-11T00:00:00.000000 (using epoch 1970-01-01T00:00:00), but Matplotlib dates must be between year 0001 and 9999.",
"stack": "---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[5], line 2
1 profile = ProfileReport(df, tsmode=True, title=\"Pandas Profiling Report\")
----> 2 profile.to_file(\"report.html\")
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/profile_report.py:379, in ProfileReport.to_file(self, output_file, silent)
376 self.config.html.assets_prefix = str(output_file.stem) + \"_assets\"
377 create_html_assets(self.config, output_file)
--> 379 data = self.to_html()
381 if output_file.suffix != \".html\":
382 suffix = output_file.suffix
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/profile_report.py:496, in ProfileReport.to_html(self)
488 def to_html(self) -> str:
489 \"\"\"Generate and return complete template as lengthy string
490 for using with frameworks.
491
(...)
494
495 \"\"\"
--> 496 return self.html
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/profile_report.py:292, in ProfileReport.html(self)
289 @property
290 def html(self) -> str:
291 if self._html is None:
--> 292 self._html = self._render_html()
293 return self._html
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/profile_report.py:409, in ProfileReport._render_html(self)
406 def _render_html(self) -> str:
407 from ydata_profiling.report.presentation.flavours import HTMLReport
--> 409 report = self.report
411 with tqdm(
412 total=1, desc=\"Render HTML\", disable=not self.config.progress_bar
413 ) as pbar:
414 html = HTMLReport(copy.deepcopy(report)).render(
415 nav=self.config.html.navbar_show,
416 offline=self.config.html.use_local_assets,
(...)
424 version=self.description_set.package[\"ydata_profiling_version\"],
425 )
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/profile_report.py:286, in ProfileReport.report(self)
283 @property
284 def report(self) -> Root:
285 if self._report is None:
--> 286 self._report = get_report_structure(self.config, self.description_set)
287 return self._report
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/report/structure/report.py:387, in get_report_structure(config, summary)
368 section_items: List[Renderable] = [
369 Container(
370 get_dataset_items(config, summary, alerts),
(...)
374 ),
375 ]
377 if len(summary.variables) > 0:
378 section_items.append(
379 Dropdown(
380 name=\"Variables\",
381 anchor_id=\"variables-dropdown\",
382 id=\"variables-dropdown\",
383 is_row=True,
384 classes=[\"dropdown-toggle\"],
385 items=list(summary.variables),
386 item=Container(
--> 387 render_variables_section(config, summary),
388 sequence_type=\"accordion\",
389 name=\"Variables\",
390 anchor_id=\"variables\",
391 ),
392 )
393 )
395 scatter_items = get_interactions(config, summary.scatter)
396 if len(scatter_items) > 0:
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/report/structure/report.py:162, in render_variables_section(config, dataframe_summary)
160 variable_type = summary[\"type\"]
161 render_map_type = render_map.get(variable_type, render_map[\"Unsupported\"])
--> 162 template_variables.update(render_map_type(config, template_variables))
164 # Ignore these
165 if reject_variables:
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/report/structure/variables/render_timeseries.py:175, in render_timeseries(config, summary)
100 table1 = Table(
101 [
102 {
(...)
133 style=config.html.style,
134 )
136 table2 = Table(
137 [
138 {
(...)
171 style=config.html.style,
172 )
174 mini_plot = Image(
--> 175 mini_ts_plot(config, summary[\"series\"]),
176 image_format=image_format,
177 alt=\"Mini TS plot\",
178 )
180 template_variables[\"top\"] = Container(
181 [info, table1, table2, mini_plot], sequence_type=\"grid\"
182 )
184 quantile_statistics = Table(
185 [
186 {
(...)
226 style=config.html.style,
227 )
File ~/anaconda3/envs/MLOps/lib/python3.12/contextlib.py:81, in ContextDecorator.__call__.<locals>.inner(*args, **kwds)
78 @wraps(func)
79 def inner(*args, **kwds):
80 with self._recreate_cm():
---> 81 return func(*args, **kwds)
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/ydata_profiling/visualisation/plot.py:708, in mini_ts_plot(config, series, figsize)
705 plot.xaxis.set_tick_params(rotation=45)
706 plt.rc(\"ytick\", labelsize=3)
--> 708 for tick in plot.xaxis.get_major_ticks():
709 if isinstance(series.index, pd.DatetimeIndex):
710 tick.label1.set_fontsize(6)
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/matplotlib/axis.py:1666, in Axis.get_major_ticks(self, numticks)
1651 r\"\"\"
1652 Return the list of major `.Tick`\\s.
1653
(...)
1663 Use `.set_tick_params` instead if possible.
1664 \"\"\"
1665 if numticks is None:
-> 1666 numticks = len(self.get_majorticklocs())
1668 while len(self.majorTicks) < numticks:
1669 # Update the new tick label properties from the old.
1670 tick = self._get_tick(major=True)
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/matplotlib/axis.py:1531, in Axis.get_majorticklocs(self)
1529 def get_majorticklocs(self):
1530 \"\"\"Return this Axis' major tick locations in data coordinates.\"\"\"
-> 1531 return self.major.locator()
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/matplotlib/dates.py:1314, in AutoDateLocator.__call__(self)
1312 def __call__(self):
1313 # docstring inherited
-> 1314 dmin, dmax = self.viewlim_to_dt()
1315 locator = self.get_locator(dmin, dmax)
1316 return locator()
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/matplotlib/dates.py:1099, in DateLocator.viewlim_to_dt(self)
1097 if vmin > vmax:
1098 vmin, vmax = vmax, vmin
-> 1099 return num2date(vmin, self.tz), num2date(vmax, self.tz)
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/matplotlib/dates.py:484, in num2date(x, tz)
458 \"\"\"
459 Convert Matplotlib dates to `~datetime.datetime` objects.
460
(...)
481 For details, see the module docstring.
482 \"\"\"
483 tz = _get_tzinfo(tz)
--> 484 return _from_ordinalf_np_vectorized(x, tz).tolist()
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/numpy/lib/function_base.py:2372, in vectorize.__call__(self, *args, **kwargs)
2369 self._init_stage_2(*args, **kwargs)
2370 return self
-> 2372 return self._call_as_normal(*args, **kwargs)
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/numpy/lib/function_base.py:2365, in vectorize._call_as_normal(self, *args, **kwargs)
2362 vargs = [args[_i] for _i in inds]
2363 vargs.extend([kwargs[_n] for _n in names])
-> 2365 return self._vectorize_call(func=func, args=vargs)
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/numpy/lib/function_base.py:2455, in vectorize._vectorize_call(self, func, args)
2452 # Convert args to object arrays first
2453 inputs = [asanyarray(a, dtype=object) for a in args]
-> 2455 outputs = ufunc(*inputs)
2457 if ufunc.nout == 1:
2458 res = asanyarray(outputs, dtype=otypes[0])
File ~/anaconda3/envs/MLOps/lib/python3.12/site-packages/matplotlib/dates.py:350, in _from_ordinalf(x, tz)
347 dt = (np.datetime64(get_epoch()) +
348 np.timedelta64(int(np.round(x * MUSECONDS_PER_DAY)), 'us'))
349 if dt < np.datetime64('0001-01-01') or dt >= np.datetime64('10000-01-01'):
--> 350 raise ValueError(f'Date ordinal {x} converts to {dt} (using '
351 f'epoch {get_epoch()}), but Matplotlib dates must be '
352 'between year 0001 and 9999.')
353 # convert from datetime64 to datetime:
354 dt = dt.tolist()
ValueError: Date ordinal 24208860.0 converts to 68251-08-11T00:00:00.000000 (using epoch 1970-01-01T00:00:00), but Matplotlib dates must be between year 0001 and 9999."
} |
Hi @bruno2009 , this is waiting for the next release to be widely available (planned for tomorrow). Nevertheless, the version of Ydata-profiling that you are using does not seem correct - ydata_profiling version: 0.0.dev0. From where and how are you installing the package? Can you provide more insights? Cheers. |
Hi all,
here are the list of packages (from pip3 freeze):
*Python 3.9.6*
altair==4.0.0
annotated-types==0.7.0
appnope==0.1.4
asttokens==2.4.1
attrs==23.2.0
blinker==1.8.2
blosc2==2.5.1
branca==0.7.2
cachetools==5.4.0
certifi==2024.6.2
charset-normalizer==3.3.2
click==8.1.7
click-plugins==1.1.1
cligj==0.7.2
comm==0.2.2
contourpy==1.2.1
cycler==0.12.1
dacite==1.8.1
debugpy==1.8.1
decorator==5.1.1
entrypoints==0.4
exceptiongroup==1.2.1
executing==2.0.1
filelock==3.15.4
fiona==1.9.6
folium==0.17.0
fonttools==4.53.1
fsspec==2024.6.1
gensim==4.3.3
geographiclib==2.0
geopandas==0.14.4
geopy==2.4.1
gitdb==4.0.11
GitPython==3.1.43
htmlmin==0.1.12
idna==3.7
ImageHash==4.3.1
importlib_metadata==7.1.0
importlib_resources==6.4.0
ipykernel==6.29.4
ipython==8.18.1
ipywidgets==8.1.3
jedi==0.19.1
Jinja2==3.1.4
joblib==1.4.2
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
jupyter_client==8.6.1
jupyter_core==5.7.2
jupyterlab_widgets==3.0.11
kiwisolver==1.4.5
llvmlite==0.43.0
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.9.1
matplotlib-inline==0.1.7
mdurl==0.1.2
mpmath==1.3.0
msgpack==1.0.8
multimethod==1.12
ndindex==1.8
nest-asyncio==1.6.0
networkx==3.2.1
numba==0.60.0
numexpr==2.10.1
numpy==1.26.4
osmnx==1.9.3
packaging==24.0
pandas==1.5.3
pandas-profiling==3.6.6
parso==0.8.4
patsy==0.5.6
pexpect==4.9.0
phik==0.12.4
pillow==10.4.0
platformdirs==4.2.2
plotly==5.23.0
prompt-toolkit==3.0.43
protobuf==3.20.3
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
py-cpuinfo==9.0.0
pyarrow==17.0.0
pydantic==2.8.2
pydantic_core==2.20.1
pydeck==0.9.1
Pygments==2.18.0
Pympler==1.1
pyparsing==3.1.2
pyproj==3.6.1
python-dateutil==2.9.0.post0
pytz==2024.1
PyWavelets==1.6.0
PyYAML==6.0.1
pyzmq==26.0.3
referencing==0.35.1
requests==2.32.3
rich==13.7.1
rpds-py==0.19.0
scikit-learn==1.5.1
scipy==1.13.1
seaborn==0.13.2
semver==3.0.2
shapely==2.0.4
six==1.16.0
smart-open==7.0.4
smmap==5.0.1
stack-data==0.6.3
statsmodels==0.14.2
stqdm==0.0.5
streamlit==1.18.1
streamlit-option-menu==0.3.13
streamlit-pandas==0.0.9
streamlit-pandas-profiling==0.1.3
streamlit_folium==0.22.0
sympy==1.13.1
tables==3.9.2
tdqm==0.0.1
tenacity==8.5.0
threadpoolctl==3.5.0
toml==0.10.2
toolz==0.12.1
torch==2.3.1
tornado==6.4
tqdm==4.66.4
traitlets==5.14.3
typeguard==4.3.0
typing_extensions==4.11.0
tzdata==2024.1
tzlocal==5.2
urllib3==2.2.2
validators==0.33.0
visions==0.7.6
wcwidth==0.2.13
widgetsnbextension==4.0.11
wordcloud==1.9.3
wrapt==1.16.0
xyzservices==2024.6.0
ydata-profiling==4.9.0
zipp==3.18.2
Fabiana ***@***.***> ezt írta (időpont: 2024. aug. 26., H,
16:32):
… Hi @bruno2009 <https://github.com/bruno2009> ,
this is waiting for the next release to be widely available (planned for
tomorrow).
Nevertheless, the version of Ydata-profiling that you are using does not
seem correct - ydata_profiling version: 0.0.dev0.
From where and how are you installing the package? Can you provide more
insights?
Cheers.
—
Reply to this email directly, view it on GitHub
<#1631 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIBQQK45HGCNOPE7BTEN6XTZTM4A3AVCNFSM6AAAAABLQ6JIBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJQGM3DKOJXHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This is the command that I used to install the package: conda install -c conda-forge ydata-profiling However, does not matter which one I choose in order to install the package (If it is pip or conda) both of them are given the same version output. |
Current Behaviour
I get the following error:
Expected Behaviour
Compiled & rendered report
Data Description
See code snippet.
Code that reproduces the bug
pandas-profiling version
latest
Dependencies
OS
Macos
Checklist
The text was updated successfully, but these errors were encountered: