gpt4 book ai didi

python - Pandas : How can I find missing data which is existing in only one data frame?

转载 作者:行者123 更新时间:2023-12-01 03:09:21 25 4
gpt4 key购买 nike

In [4]: chois_df.head()
Out[4]:
word doc tf
0 reason 10 0.571429
1 moderately 10 0.571429
2 bad 10 0.642857
3 coherence 10 0.571429
4 inviolable 10 0.571429

In [6]: test_df.head()
Out[6]:
word doc tf
0 reason 10 0.571429
1 moderately 10 0.571429
2 bad 10 0.642857
3 coherence 10 0.571429
4 inviolable 10 0.571429

In [2]: chois_df.count()
Out[2]:
word 260800
doc 260801
tf 260801
dtype: int64

In [3]: test_df.count()
Out[3]:
word 260742
doc 260743
tf 260743
dtype: int64

如上所示,chois_dfword 多于 test_df

如何找到 chois_df 中哪些单词是多余的?

由于数据帧的长度不同,因此比较它们有点困难。

需要您的建议,谢谢。

最佳答案

简单点怎么样

all = chois_df.merge(test_df, how = 'left', on = ['word', 'doc'], indicator = True)
all[all._merge == 'left_only']

关于python - Pandas : How can I find missing data which is existing in only one data frame?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43024113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com