inner join/merge in pandas dataframe give more rows than left dataframe

后端 未结 1 1009
北海茫月
北海茫月 2021-01-18 22:09

Here are how the dataframes columns look like.

df1=\'device number\', \'date\', ....<<10 other columns>> 3500 records

df2=\'device number\', \'date\',

1条回答
  •  有刺的猬
    2021-01-18 22:38

    Only way I can see this happening... particularly with the 14,000 being the same exact number as the number of records in df2 is if the column combination in df2 are not unique.

    You can verify that they are not unique with the following (True if unique)

    df2.duplicated(['device number', 'date']).sum() == 0
    

    Or

    df.set_index(['device number', 'date']).index.is_unique
    

    0 讨论(0)
提交回复
热议问题