Skip to content

BUG: DatetimeIndex.weekofyear gives AttributeError #55092

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

Closed
3 tasks done
this-josh opened this issue Sep 11, 2023 · 7 comments
Closed
3 tasks done

BUG: DatetimeIndex.weekofyear gives AttributeError #55092

this-josh opened this issue Sep 11, 2023 · 7 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@this-josh
Copy link

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

>>> import pandas as pd
>>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
>>> idx.week
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'DatetimeIndex' object has no attribute 'week'
>>> idx.weekday # sanity check
Index([2, 5], dtype='int32')
>>> idx.weekofyear
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'DatetimeIndex' object has no attribute 'weekofyear'

Issue Description

weekofyear doesn't seem to be working

Expected Behavior

The week dts week of the year as an integer should be returned

Installed Versions

pd.show_versions()
/private/tmp/envs/lib/python3.11/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")

INSTALLED VERSIONS

commit : 723feb9
python : 3.11.5.final.0
python-bits : 64
OS : Darwin
OS-release : 22.6.0
Version : Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 2.2.0dev0+208.g723feb984
numpy : 1.25.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.1.2
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@this-josh this-josh added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 11, 2023
@mroeschke
Copy link
Member

This was deprecated in 1.1.0 and now it's suggested to use DatetimeIndex.isocalendar().week instead

@this-josh
Copy link
Author

This was deprecated in 1.1.0 and now it's suggested to use DatetimeIndex.isocalendar().week instead

It should be removed from the docs if that is the case.

@mroeschke
Copy link
Member

Could you share where this still exists in the docs?

@this-josh
Copy link
Author

@tray3j
Copy link

tray3j commented Mar 18, 2024

@mroeschke The reference to week and weekofyear attributes still exists in the user gude, link here: Time/date components.

@tray3j
Copy link

tray3j commented Mar 18, 2024

I opened this issue: #57887

@sorenwacker
Copy link

df.col.dt.isocalendar().week ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

4 participants