Reputation: 53
Use the dframe from pandas module:
df = dframe.resample('t', how = 'sum')
And after that I want to write the data in a new file. I use this:
with open('dframe.txt', 'w') as fout:
fout.write(df.price1) #it is the first column
But it doesn't work.
Upvotes: 3
Views: 11301
Reputation: 734
Did you try to use .values
?
with open('dframe.txt', 'w') as fout:
fout.write(df.price1.values)
It returns a list containing all column values.
Upvotes: 0
Reputation: 795
FYI there is also:
Only needed to use to_excel: the usage is in the method documentation or on http://pandas.pydata.org/pandas-docs/stable/
Upvotes: 0
Reputation: 80346
df.price1
returns a Series
. Luckily Series
also has a to_csv
method similar to the DataFrame's
:
Definition: Series.to_csv(self, path, index=True, sep=',', na_rep='',
float_format=None, header=False, index_label=None, mode='w', nanRep=None,
encoding=None)
Example usage:
df.price1.to_csv('outfile.csv')
Upvotes: 9