I have two data frame df1
, df2
, which I want to combine to the new dataframe df
. This however creates an row with all NaN:
>>> from pandas import DataFrame
>>> df1 = DataFrame({'col1':[1,2,3], 'col2':[2,3,4]})
>>> df2 = DataFrame({'col1':[4,2,5], 'col2':[6,3,5]})
>>> df = df2[~df2.isin(df1)]
>>> df
col1 col2
0 4 6
1 NaN NaN
2 5 5
How can I remove this row, such that df
looks like:
>>> df
col1 col2
0 4 6
2 5 5
You could use dropna:
In [13]: df2[df1 != df2].dropna(how='all')
Out[13]:
col1 col2
0 4 6
2 5 5
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