我正在尝试使用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的第三列?它似乎以非常意外的方式打印。
另外,如何在读取数据帧时删除行号?
感谢。