I have a dataset that has a column called Founded. The founded column contains a variety of years in which a company was founded also the datatype for the column is int64. I have a for loop that is supposed to alter the column based on the if statements
for i in range(2253):
if type(df['Founded'].iloc[i])== int :
if df['Founded'].iloc[i]>2000.0 :
df['Founded'].iloc[i]= 'After 2000'
elif 1950.0 <df['Founded'].iloc[i]<=2000.0 :
df['Founded'].iloc[i]= 'Between 1951-2000'
elif 1900.0 <df['Founded'].iloc[i]<=1950.0 :
df['Founded'].iloc[i]= 'Between 1901-1950'
elif df['Founded'].iloc[i]<1900.0 :
df['Founded'].iloc[i]= 'Before 1900'
else :
df['Founded'].iloc[i]=None
i=i+1
But after I run the code and check the column Founded everthing is changed into Nan. Any suggestions as to what I am do wrong?
Aucun commentaire:
Enregistrer un commentaire