import pandas as pd
import numpy as np
import glob
# combine time for one set
def draw_comb_time(path):
draw_time(cat_data(path))
# combine data together
def cat_data(path):
csv = glob.glob(path + '/*.csv')
csv_all = [pd.read_csv(f) for f in csv]
df = [pd.DataFrame(d) for d in csv_all]
data = pd.concat(df)
return data
def draw_time(data):
df = pd.DataFrame(data)
cumsum = []
ticks = [i for i in np.linspace(0, 10000, 51)]
for i in ticks:
cumsum.append(df.iloc[:int(i)].sum())
d = pd.DataFrame(cumsum)
d.plot
draw_comb_time('sage')
It gives me the error:
/usr/bin/python3.5 /home/zhangysh1995/work/results/scripts/tests.py
Traceback (most recent call last):
File "/home/zhangysh1995/work/results/scripts/tests.py", line 28, in <module>
draw_comb_time('../Out/sage')
File "/home/zhangysh1995/work/results/scripts/tests.py", line 6, in draw_comb_time
draw_time(cat_data(path))
File "/home/zhangysh1995/work/results/scripts/tests.py", line 25, in draw_time
d.plot()
File "/usr/local/lib/python3.5/dist-packages/pandas/plotting/_core.py", line 2627, in __call__
sort_columns=sort_columns, **kwds)
File "/usr/local/lib/python3.5/dist-packages/pandas/plotting/_core.py", line 1869, in plot_frame
**kwds)
File "/usr/local/lib/python3.5/dist-packages/pandas/plotting/_core.py", line 1694, in _plot
plot_obj.generate()
File "/usr/local/lib/python3.5/dist-packages/pandas/plotting/_core.py", line 243, in generate
self._compute_plot_data()
File "/usr/local/lib/python3.5/dist-packages/pandas/plotting/_core.py", line 352, in _compute_plot_data
'plot'.format(numeric_data.__class__.__name__))
TypeError: Empty 'DataFrame': no numeric data to plot
Process finished with exit code 1
--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I use Pandas to process data attached(sage.tar) on Ubuntu 16.04 (download the attached file, tar it and just copy and paste the following code):