I have a DataFrame like this (first column is index
(786...) and second day
(25...) and Rainfall amount
is empty):
Day Rainfall amount (millimetres) 786 25 787 26 788 27 789 28 790 29 791 1 792 2 793 3 794 4 795 5
and I want to delete the row 790. I tried so many things with df.drop but nothin happend.
I hope you can help me.
To delete a row from a DataFrame, use the drop() method and set the index label as the parameter.
Pandas provides data analysts with a way to delete and filter dataframe using . drop() method. Columns can be removed permanently using column name using this method df. drop(['your_column_name'], axis=1, inplace=True) .
While dropping new DataFrame returns. If you want to apply changes to the current DataFrame you have to specify inplace
parameter.
Option 1
Assigning back to df
-
df = df.drop(790)
Option 2
Inplace argument -
df.drop(790, inplace=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With