dataframe 相减
时间: 2023-09-09 20:08:55 浏览: 95
Pandas DataFrame Notes
要对两个DataFrame进行相减,可以使用`pd.concat()`函数将两个DataFrame合并,并使用`drop_duplicates()`函数删除重复的行。具体代码如下所示:
```python
data_1 = pd.concat(\[data, sec_data, sec_data\]).drop_duplicates(keep=False)
```
这样就可以得到两个DataFrame的差集`data_1`。\[1\]
#### 引用[.reference_title]
- *1* *2* *3* [将DataFrame中出现过一次的行进行删除;两个DataFrame求交集、求差](https://blog.csdn.net/m0_51099057/article/details/122342642)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文