def write_csv(df, filename):
""" Write a pandas dataframe to CSV in a standard way """
# Verify that the data do not contain commas
for col in df.select_dtypes([np.object]):
if df[col].str.contains(',').any():
raise ValueError("Failed write to %s: Column %s contains commas" % (filename, col))
df.to_csv(filename, header=True, index=False, sep=',')
评论列表
文章目录