Data-Analysis icon indicating copy to clipboard operation
Data-Analysis copied to clipboard

TypeError: <class 'datetime.date'> type object 2015-03-27

Open yoonguk510 opened this issue 7 years ago • 9 comments

I am getting this error

File "D:\anaconda\lib\site-packages\pandas\core\indexes\datetimes.py", line 133, in wrapper

TypeError: <class 'datetime.date'> type object 2015-03-27

yoonguk510 avatar Aug 13 '18 12:08 yoonguk510

I also met this error... Have you solve this problem?

julietxiao avatar Oct 07 '18 11:10 julietxiao

Yes I have. There is a problem with the python file. You have to run it via jupiter notebook. It will work fine.

On Sun, Oct 7, 2018, 8:13 PM julietxiao [email protected] wrote:

I also met this error... Have you solve this problem?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WillKoehrsen/Data-Analysis/issues/16#issuecomment-427644969, or mute the thread https://github.com/notifications/unsubscribe-auth/AaqjaWlmSU7GA-HqMXws2jJYKB-kBLHPks5uieHGgaJpZM4V6ZmT .

yoonguk510 avatar Oct 09 '18 08:10 yoonguk510

I think this is an issue with the version of Pandas. Which version of Pandas were you using when you got the error?

WillKoehrsen avatar Nov 30 '18 18:11 WillKoehrsen

I think this is an issue with the version of Pandas. Which version of Pandas were you using when you got the error?

I think you are spot on. I got this message regarding this:

FutureWarning: Comparing Series of datetimes with 'datetime.date'. Currently, the 'datetime.date' is coerced to a datetime. In the future pandas will not coerce, and a TypeError will be raised. To retain the current behavior, convert the 'datetime.date' to a datetime with 'pd.Timestamp'.

In the installation I have for Stocker, this is the version of Pandas and its dependencies Note that it is in a conda env that makes everything work (I had troubles making fbprophet work due to versions of pystan and others):

>>> pd.show_versions(as_json=False)

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: 0.29.3
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Hope this helps. Will try to go into it to see if I can modify Stocker.py to use new Pandas method. Regards.

VictorHM avatar Jan 20 '19 15:01 VictorHM

I'm having the same problem and went through similar install issues as described by @VictorHM.

I'm new to Python so I'd apppriciate if one could point out a solution or workaround.

Thanks a lot!

sebdau avatar Jan 23 '19 18:01 sebdau

#22 Solved the type problem for me!

sebdau avatar Jan 24 '19 12:01 sebdau

I got the same problem with pandas0.23.4, just as described by VictorHM. Solved the problem by "pd.to_datetime(df['date'], format='%Y%m%d').apply(lambda x: x.date())".the stackoverflow link is here

htuhxf avatar Apr 08 '19 03:04 htuhxf

Late, but thank you for your help :)

On Mon, Apr 8, 2019 at 12:20 PM Sean [email protected] wrote:

I got the same problem with pandas0.23.4, just as described by VictorHM. Solved the problem by "pd.to_datetime(df['date'], format='%Y%m%d').apply(lambda x: x.date())".the stackoverflow link is here https://stackoverflow.com/questions/41783003/how-do-i-convert-timestamp-to-datetime-date-in-pandas-dataframe

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WillKoehrsen/Data-Analysis/issues/16#issuecomment-480669638, or mute the thread https://github.com/notifications/unsubscribe-auth/AaqjaR6KhHuDVAK-tZu54KihMVtFJhx_ks5verVmgaJpZM4V6ZmT .

yoonguk510 avatar Aug 12 '19 18:08 yoonguk510

I think you are spot on. I got this message regarding this:

FutureWarning: Comparing Series of datetimes with 'datetime.date'. Currently, the 'datetime.date' is coerced to a datetime. In the future pandas will not coerce, and a TypeError will be raised. To retain the current behavior, convert the 'datetime.date' to a datetime with 'pd.Timestamp'.

wrapping the datetime in pd.Timestamp(<your_date>) worked for me to get around that warning.

angelotc avatar Jan 02 '20 02:01 angelotc