1

请问 pandas.concat 合并多个 csv 时候会发生每个文件和楼梯一样错开的排列

 2 years ago
source link: https://www.v2ex.com/t/841737
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Python

请问 pandas.concat 合并多个 csv 时候会发生每个文件和楼梯一样错开的排列

  iochrome · 11 小时 39 分钟前 · 279 次点击

图片如下 /t image

我想 pands.concat()不是应该是下面的效果的 /t image

我是这样写的

import os
import pandas as pd

df1 = pd.read_csv("BTCUSDT-1m-2022-03-18.csv", index=False, header = None)
df2 = pd.read_csv("BTCUSDT-1m-2022-03-17.csv", index=False, header = None)
df3 = pd.read_csv("BTCUSDT-1m-2022-03-16.csv", index=False, header = None)
df_m = pd.concat([df1,df2,df3])
df_m.to_csv('file.csv', header = None)

系统是 wsl-ubuntu18.04

第 1 条附言  ·  1 小时 5 分钟前

这个是在windows用excle 打开浏览的状态 image

所有cvs的右侧有一排0,就只有第一个输出有0,会不会就是这个差别,才导致后面的错误,但是为何后面会少了0呢? 文档没有说过会默认删除为0的列啊。

不过今天早上重新运行一遍又完成了文档介绍的效果了,只有整列,完全没有昨晚楼梯拼接的影子了。我到底遇到什么了 为何我总是遇到这种奇奇怪怪的问题


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK