close

[Solved] Error in reading stock data : ‘DatetimeProperties’ object has no attribute ‘weekday_name’ and ‘NoneType’ object has no attribute ‘to_csv’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Error in reading stock data : ‘DatetimeProperties’ object has no attribute ‘weekday_name’ and ‘NoneType’ object has no attribute ‘to_csv’ in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Error in reading stock data : ‘DatetimeProperties’ object has no attribute ‘weekday_name’ and ‘NoneType’ object has no attribute ‘to_csv’ Error Occurs?

Today I get the following error Error in reading stock data : ‘DatetimeProperties’ object has no attribute ‘weekday_name’ and ‘NoneType’ object has no attribute ‘to_csv’ in Python.

How To Solve Error in reading stock data : ‘DatetimeProperties’ object has no attribute ‘weekday_name’ and ‘NoneType’ object has no attribute ‘to_csv’ Error ?

  1. How To Solve Error in reading stock data : 'DatetimeProperties' object has no attribute 'weekday_name' and 'NoneType' object has no attribute 'to_csv' Error ?

    To Solve Error in reading stock data : 'DatetimeProperties' object has no attribute 'weekday_name' and 'NoneType' object has no attribute 'to_csv' Error We can use df['Weekday'] = df['Date'].dt.strftime("%A")
    This will give the weekday names

  2. Error in reading stock data : 'DatetimeProperties' object has no attribute 'weekday_name' and 'NoneType' object has no attribute 'to_csv'

    To Solve Error in reading stock data : 'DatetimeProperties' object has no attribute 'weekday_name' and 'NoneType' object has no attribute 'to_csv' Error We can use df['Weekday'] = df['Date'].dt.strftime("%A")
    This will give the weekday names

Solution 1

Your problem is the following line:

df['Weekday'] = df['Date'].dt.weekday_name

Change it to:

df['Weekday'] = df['Date'].dt.day_name()

and you’re fine to go.

Solution 2

We can use df['Weekday'] = df['Date'].dt.strftime("%A")
This will give the weekday names

More formatting options include:

%A -Full weekday name like MONDAY, TUESDAY etc
%w -Weekday as a decimal number like 1,2,3 etc
%a -Abbreviated weekday name like SUN,MON etc
%Y -year
%m -month
%d -day
%H -hours
%M -minutes
%S -seconds

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment