I am doing a coursera course and want to create various dataframe using for loop, the idea is to create a list and then add each df into the list. However, below come back with error:
File "<ipython-input-10-2863e455a5c5>", line 7
array.append(county_df.where(county_df['STNAME']=state))
^
SyntaxError: keyword can't be an expression
census_df = pd.read_csv('census.csv')
county_df=census_df[census_df['SUMLEV'] == 50]
county_df.head()
county_df['STNAME'].unique()
list = []
print type(list)
for state in county_df['STNAME'].unique():
array.append(county_df.where(county_df['STNAME']=state))
print (list)
arrayshouldn't be list?list.