Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weekday name from a pandas dataframe Date object [duplicate]

I would like to get the weekday name for all my date. I have a pandas df which has a Date column formatted to datetime64[ns]

i have tried the following

data['Date'].dt.weekday_name

and I get the response

data['Date'].dt.weekday_name
Traceback (most recent call last):

  File "<ipython-input-207-e57074c4e346>", line 1, in <module>
    data['Date'].dt.weekday_name

AttributeError: 'DatetimeProperties' object has no attribute 'weekday_name'

Please help

like image 681
John Doe Avatar asked Feb 21 '20 12:02

John Doe


People also ask

How do I find my weekday name on pandas?

weekday_name attribute return the name of the day of the week for the given date in the Timestamp object. Example #1: Use Timestamp. weekday_name attribute to find the name of the weekday for the given date in the Timestamp object.

How do I print the day name in Python?

Use the weekday() Method to Get the Name of the Day in Python. In Python, weekday() can be used to retrieve the day of the week. The datetime. today() method returns the current date, and the weekday() method returns the day of the week as an integer where Monday is indexed as 0 and Sunday is 6.


1 Answers

Maybe you can use day_name:

df['Date'].dt.day_name()
like image 50
zipa Avatar answered Sep 22 '22 01:09

zipa