I have two data frames as given below
small_df =
index data1
2 123
3 436
big_df =
index data1
0 78
1 67
2 13
3 46
I want to compare check if any index of small_df present in big_df using a one line code and produce True or False. My code:
big_idx = [True for i in small_df.index if i in big_df.index]
My present output
big_idx = [True True]
My expected output
big_idx = [False False True True]
How to insert False in my code? I tried following code but not successful.
[True for i in small_df.index if i in big_df.index else False]
Aucun commentaire:
Enregistrer un commentaire