Pandas AttributeError: 'DataFrame' object has no attribute ...
stackoverflow.com › questions › 52182361Jan 01, 2013 · import pandas as pd data = {'Year': [2013, 2013, 2013, 2014, 2014], 'Rate': [34.7, 34.6,34.6,35.3,34.18]} df = pd.DataFrame (data, columns= ["Year", "Rate"]) df.Timestamp = pd.to_datetime (df.Datetime,format='%Y') # AttributeError: 'DataFrame' object has no attribute 'Datetime'. You should reference Year instead: df ['Timestamp'] = pd.to_datetime (df ['Year'],format='%Y') df # result: Year Rate Timestamp 0 2013 34.70 2013-01-01 1 2013 34.60 2013-01-01 2 2013 34.60 2013-01-01 3 2014 35.30 ...
DataFrame AttributeError: 'Index' object has no attribute 'date'
stackoverflow.com › questions › 62225796Jun 06, 2020 · It seems like your time_date column isn't being converted to a datetime64 object. Try adding utc=True to pd.to_datetime. This snippet works: import pandas as pd df = pd.read_csv ('sample.csv', delimiter=',', header=0, index_col=False) # convert time_date col to datetime64 dtype df ['time_date'] = pd.to_datetime (df ['time_date'], utc=True) df.set_index ('time_date', inplace=True) print (df.index.date)