I am trying to get results for specific attributes? Trying to extract month and day of the week from Start Time to create new columns then filer to get new data frame
import pandas as pd
CITY_DATA = {'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv','washington': 'washington.csv'}
def load_data(city, month, day):
df = pd.read_csv(CITY_DATA[city])
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['month'] = df['Start Time'].dt.month
df['day_of_week'] = df['Start Time'].dt.weekday_name
if month != 'all':
months = ['january', 'february', 'march', 'april', 'may', 'june']
month = months.index(month) + 1
df = df[df['month'] == month]
if day != 'all':
df = df[df['day_of_week'] == day.title()]
return df
df = load_data('chicago', 'march', 'friday')
print(df.head())
AttributeError: 'DatetimeProperties' object has no attribute 'weekday_name'