-1

let's say I have a my source dataframe:

A B C
a 1 string1
b 1 string1
b 4 string2
c 2 string4
d 2 string2

and I have my input dataframe

A B C
a null string1
b null string2

How am I able to cross check values from my input dataframe to my source I want to find which rows in my source dataframe that has values from my input dataframe. I tried isin but its returning a dataframe full of nan values

Result would be a df:

A B C
a 1 string1 #Ref to a null string1
b 1 string1 #Ref to b null string2
b 4 string2 #Ref to b null string2
d 2 string2 #Ref to b null string2
dekt
  • 51
  • 5

1 Answers1

0

It looks like you are filtering your source df keeping only rows that have values in column C that are in your input df column C. If that is the case, you can use input_df['C'].unique() to give you an array of the unique values in column C in your input df, and you can use isin to filter your source df:

source_df[source_df['C'].isin(input_df['C'].unique())]

which gives an output of:

    A   B   C
0   a   1   string1
1   b   1   string1
2   b   4   string2
4   d   2   string2
Joe Patten
  • 1,574
  • 1
  • 6
  • 15