I have 30 minute incremental data that I resampled to monthly average using Pandas. How do I paste the resampled data into a text or csv file? Please see my script and sample data below.
import pandas as pd
data = r'C:\Creek\data\30Min_flow.csv'
flowdata=pd.read_csv(data,parse_dates='DateTime',index_col=0)
monthly=flowdata.resample('M',how='mean')
I would like to print the monthly variable into a text or csv file. Below I have a sample of the data.
DateTime F1_cfs F2_cfs F3_cfs F4_cfs F5_cfs F6_cfs F7_cfs
1/20/1992 9:30 0.23 0.34 0.34 0.8 1.01 2.24 1.4
1/20/1992 10:00 0.22 0.34 0.33 0.8 1.01 2.24 1.4
1/20/1992 10:30 0.22 0.34 0.33 0.8 1.01 2.24 1.4
1/20/1992 11:00 0.22 0.34 0.33 0.8 1.01 2.24 1.4
1/20/1992 11:30 0.21 0.34 0.33 0.8 1.01 2.24 1.4
1/20/1992 12:00 0.22 0.34 0.33 0.8 1.01 2.24 1.4
1/20/1992 12:30 0.22 0.34 0.33 0.8 1.01 2.24 1.4
试试.to_csv
:
monthly.to_csv(r'c:\Creek\data\monthly.csv')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.