Skip to content

BUG: Timestamp.weekday_name uses UTC instead of given timezone #17354

Closed
@evanunderscore

Description

@evanunderscore

Code Sample, a copy-pastable example if possible

import pandas as pd

# Create a Timestamp for 11pm Monday 28th
ts = pd.Timestamp('2017-08-28 23:00:00')
# Both weekday() and weekday_name indicate this is a Monday
assert ts.weekday() == 0
assert ts.weekday_name == 'Monday'

# Now localize the timezone
ts = ts.tz_localize('EST')
# weekday() still says Monday, but weekday_name says Tuesday!
assert ts.weekday() == 0
assert ts.weekday_name == 'Tuesday'

Problem description

For pd.Timestamp objects with timezone information, the weekday_name attribute appears to give the name of the weekday in UTC (in the above example, this would be 2017-08-29 04:00:00), whereas weekday() uses local time. I could find no mention of this difference in the documentation for weekday and weekday_name. I would expect both to work in the given timezone.

Expected Output

Expected:
>>> pd.Timestamp('2017-08-28 23:00:00', tz='EST').weekday_name
'Monday'

Actual:
>>> pd.Timestamp('2017-08-28 23:00:00', tz='EST').weekday_name
'Tuesday'

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: C
LANG: None
LOCALE: None.None

pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 36.2.7
Cython: None
numpy: 1.13.1
scipy: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.7.3.1 (dt dec pq3 ext lo64)
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions