Consider the following data block
import pandas as pd df = pd.DataFrame({'A' : [1, 2, 3, 3, 4, 4, 5, 6, 7], 'B' : ['a','b','c','c','d','d','e','f','g'], 'Col_1' :[np.NaN, 'A','A', np.NaN, 'B', np.NaN, 'B', np.NaN, np.NaN], 'Col_2' :[2,2,3,3,3,3,4,4,5]}) df Out[92]: AB Col_1 Col_2 0 1 a NaN 2 1 2 b A 2 2 3 c A 3 3 3 c NaN 3 4 4 d B 3 5 4 d NaN 3 6 5 e B 4 7 6 f NaN 4 8 7 g NaN 5
I want to delete all rows that are duplicates relative to column 'A' 'B' . I want to delete a record with a NaN record (I know that for all dulicates there will be a NaN record and not- NaN record). The final results should look like this:
AB Col_1 Col_2 0 1 a NaN 2 1 2 b A 2 2 3 c A 3 4 4 d B 3 6 5 e B 4 7 6 f NaN 4 8 7 g NaN 5
We welcome all effective, single-line.