如何从 Web 索引合并的 CSV 文件
How do I index a merged CSV file from the web
我需要帮助从网络上正确索引我的数据框。我正在使用 pandas 模块
df1 = pd.read_csv('https://raw.githubusercontent.com/bonsalakot00/Test-Server/master/Data_2012.csv')
这是我用于访问我的数据存储库并将其作为数据框读取的代码之一
frames = [df1, df2, df3, df4, df5, df6]
result = df1.append(frames, sort=False)
print(result)
这是我尝试自动将我的数据帧从 [1 到 258] 排序的代码,我尝试执行 result=pd.concat([df1],[df2],[df3],[df4],[df5],[df6],[df7], axis=1, join='inner').sort_index()
以正确排序数字,但它最终使每个计数加倍。
This is the image of what I'm trying to describe
如果您担心每个索引号的倍数,您可以简单地重新设置索引。
results = pd.concat([df1, ..., dfn], axis=0, join='inner')
results = result.reset_index(drop=True)
result = pd.concat(df1,...,dfn], axis = 0, ignore_index = True, join = 'inner')
ignore_index = True, will sort your combined CSV file from [0 to nth]
我需要帮助从网络上正确索引我的数据框。我正在使用 pandas 模块
df1 = pd.read_csv('https://raw.githubusercontent.com/bonsalakot00/Test-Server/master/Data_2012.csv')
这是我用于访问我的数据存储库并将其作为数据框读取的代码之一
frames = [df1, df2, df3, df4, df5, df6]
result = df1.append(frames, sort=False)
print(result)
这是我尝试自动将我的数据帧从 [1 到 258] 排序的代码,我尝试执行 result=pd.concat([df1],[df2],[df3],[df4],[df5],[df6],[df7], axis=1, join='inner').sort_index()
以正确排序数字,但它最终使每个计数加倍。
This is the image of what I'm trying to describe
如果您担心每个索引号的倍数,您可以简单地重新设置索引。
results = pd.concat([df1, ..., dfn], axis=0, join='inner')
results = result.reset_index(drop=True)
result = pd.concat(df1,...,dfn], axis = 0, ignore_index = True, join = 'inner')
ignore_index = True, will sort your combined CSV file from [0 to nth]