I want to iterate through the columnn df['Social Distancing Advisory'] and replace various elements by another, but nothing seems to work when I set it up like this.
df looks like this State Social Distancing Advisory Date (effective) status new order until details
import pandas as pd
df = pd.read_excel('/Users/Arthur/Desktop/COVID-RA/state_data.xlsx')
for column in df['Social Distancing Advisory']:
if df['Social Distancing Advisory'] == 'sah':
df['Social Distancing Advisory'].replace('sah','1')
if df['Social Distancing Advisory'] == 'sip':
df['Social Distancing Advisory'].replace('sip','0')
df
Aucun commentaire:
Enregistrer un commentaire