我的代码是这样的:
raw_data={'Crest_height':[crest_day.Crest],
'Date':[crest_day.Date],
'Flood_Response':[flood_response]}
Flood_data=pd.DataFrame(raw_data)
Flood_data.to_csv(r'crest_day.csv', index=False)
我在crest_day.csv文件中输出了这个输出:
Crest_height Date Flood_Response
"4 10.82
Name: Crest, dtype: float64" "4 2016-08-18
Name: Date, dtype: datetime64[ns]" Major Flood
我希望在csv文件中有一个干净的输出,而不是dtypes,索引等, crest_day在float中有两列(Crest和Date),而flood_response是一个字符串
两者都是从函数
返回的答案 0 :(得分:0)
你可以尝试这段代码:
Flood_data=pd.DataFrame({
'Crest_height' : list(crest_day.Crest),
'Date':list(crest_day.Date),
'Flood_Response':list(flood_response)
})
Flood_data.to_csv('crest_day.csv', index=False)
希望它有所帮助。