我在玩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)
为什么在我打印dfu 10时CSV的第三列被删除了?它似乎以一种出人意料的方式印刷出来。你知道吗
另外,在读取数据帧时,如何从数据帧中删除行号?你知道吗
谢谢。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐