I have a pandas dataframe "df". In this dataframe I have multiple columns, one of which I have to substring.
Lets say the column name is "col".
I can run a "for" loop like below and substring the column:
for i in range(0,len(df)):
df.iloc[i].col = df.iloc[i].col[:9]
But I wanted to know, if there is an option where I don't have to use a "for" loop, and do it directly using an attribute.I have huge amount of data, and if I do this, the data will take a very long time process.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…