我正在使用一个脚本来创建一个数据帧,然后将其保存为桌面上的csv文件。当我运行代码时,我没有得到任何错误。但是,它不会在我指定的位置创建任何csv文件。我正在使用数据块进行编码。你知道吗
from pandas import DataFrame
Cars = {'Brand': ['Honda Civic','Toyota Corolla','Ford Focus','Audi A4'],'Price': [22000,25000,27000,35000]}
df = DataFrame(Cars, columns= ['Brand', 'Price'])
export_csv = df.to_csv(r'C:\Users\myname\Desktop\export_test.csv', index = None, header=True) #Don't forget to add '.csv' at the end of the path
您不需要将其指定给新名称(export\u csv)。下面的代码运行良好。你知道吗
相关问题 更多 >
编程相关推荐