When dropping rows with NaN's in a Pandas Dataframe, this
df = df.dopna()
may be faster than this
df.dropna(inplace=True).
Casting converting a column of a dataframe to float (for example) can be very slow if done like this:
df[col1] = pd.to_numericdf(df[col1])
or
df[col1] = df[col1].apply(pd.to_numeric)
or
df[col1] = df[col1].astype(float)
If you know how to do this efficiently, please tell me. As of now, my only work around is to avoid doing this operation if possible.
df = df.dopna()
may be faster than this
df.dropna(inplace=True).
Casting converting a column of a dataframe to float (for example) can be very slow if done like this:
df[col1] = pd.to_numericdf(df[col1])
or
df[col1] = df[col1].apply(pd.to_numeric)
or
df[col1] = df[col1].astype(float)
If you know how to do this efficiently, please tell me. As of now, my only work around is to avoid doing this operation if possible.
No comments:
Post a Comment