Pandas DataFrame似乎在采集样本时跳过列?

时间:2017-03-30 11:32:31

标签: python json python-3.x csv pycharm

我正在尝试使用python,尝试读取CSV,占用10%,然后转换为JSON。

import pandas as pd
import json

#read excel
df = pd.read_csv('C:\\Users\\ADMIN\\Desktop\\CSV_1.csv')
#printing this works fine

# Randomly sample 10% of your dataframe
df_10 = df.sample(frac=0.1)
print(df_10) # printing this seems to remove the third column of my csv

#convert excel to json for testing
json_file=df_10.to_json()

print(json_file)

为什么在打印df_10时会删除CSV的第三列?它似乎以非常意外的方式打印。

另外,如何在读取数据帧时删除行号?

感谢。

0 个答案:

没有答案