2

Wrong `weekofyear` for dates close to end of year · Issue #21971 · pandas-dev/pa...

 1 year ago
source link: https://github.com/pandas-dev/pandas/issues/21971
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Comments

import pandas as pd

d = pd.to_datetime("2008-12-30")
# This returns 1 instead of 53!!
d.weekofyear

Problem description

In some cases, dates near the end of the year yield a wrong weekofyear attribute (1 instead of 53)
Note that this does not happen for every year, eg this works:

d = pd.to_datetime("2009-12-30")
# Returns 53, as expected
d.weekofyear

but this also fails (so, it is not limited to leap years, in case you are wondering (I was)):

d = pd.to_datetime("2007-12-31")
d.weekofyear 

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-128-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK