Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change entire row if NaN present if a single column has NaN

I have a DataFrame like this

                    gauge       satellite
1979-06-23 18:00:00 6.700000    2.484378
1979-06-27 03:00:00 NaN         8.891460
1979-06-27 06:00:00 1.833333    4.053460
1979-06-27 09:00:00 NaN         2.876649
1979-07-31 18:00:00 6.066667    1.438324

I want to obtain a DataFrame Like this

                    gauge       satellite
1979-06-23 18:00:00 6.700000    2.484378
1979-06-27 03:00:00 NaN         NaN
1979-06-27 06:00:00 1.833333    4.053460
1979-06-27 09:00:00 NaN         NaN
1979-07-31 18:00:00 6.066667    1.438324
like image 796
modyrockett Avatar asked Jul 29 '19 14:07

modyrockett


People also ask

How do I remove NaN values from a data frame?

By using dropna() method you can drop rows with NaN (Not a Number) and None values from pandas DataFrame. Note that by default it returns the copy of the DataFrame after removing rows. If you wanted to remove from the existing DataFrame, you should use inplace=True .


1 Answers

What I will do reindex

df.dropna().reindex(df.index)
like image 180
BENY Avatar answered Nov 14 '22 21:11

BENY