2个dataframe 竖着拼
时间: 2023-10-20 19:02:46 浏览: 91
要将两个DataFrame竖着拼接,可以使用pandas库中的concat函数,并指定axis参数为0。下面是一个示例代码:
```python
import pandas as pd
df1 = pd.DataFrame([10,12,13])
df2 = pd.DataFrame([22,33,44,55])
result = pd.concat([df1, df2], axis=0)
```
其中,df1和df2是要拼接的两个DataFrame,concat函数的axis参数表示拼接的方向,0表示竖直方向。拼接后的结果保存在result变量中。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [pandas.concat实现DataFrame竖着拼接、横着拼接](https://blog.csdn.net/craftsman2020/article/details/129239859)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [dataframe设置两个条件取值的实例](https://download.csdn.net/download/weixin_38581777/14864036)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文