Drop all data in a pandas dataframe
You need to pass the labels to be dropped.
df.drop(df.index, inplace=True)
By default, it operates on axis=0
.
You can achieve the same with
df.iloc[0:0]
which is much more efficient.
My favorite:
df = df.iloc[0:0]
But be aware df.index.max() will be nan. To add items I use:
df.loc[0 if math.isnan(df.index.max()) else df.index.max() + 1] = data
My favorite way is:
df = df[0:0]