Open sitexa opened 1 year ago
Which exceptions were raised?
The errors were as following:
python outputs/plot.py -f tests/ppo_conn0_ep2.csv
Traceback (most recent call last):
File "/Users/xnpeng/sumoptis/sumo-rl/outputs/plot.py", line 90, in <module>
plot_df(main_df, xaxis=args.xaxis, yaxis=args.yaxis, label=next(labels), color=next(colors), ma=args.ma)
File "/Users/xnpeng/sumoptis/sumo-rl/outputs/plot.py", line 43, in plot_df
df[yaxis] = pd.to_numeric(df[yaxis], errors="coerce") # convert NaN string to NaN value
File "/Users/xnpeng/miniforge3/envs/sumoai/lib/python3.10/site-packages/pandas/core/frame.py", line 3761, in __getitem__
indexer = self.columns.get_loc(key)
File "/Users/xnpeng/miniforge3/envs/sumoai/lib/python3.10/site-packages/pandas/core/indexes/range.py", line 349, in get_loc
raise KeyError(key)
KeyError: 'system_total_waiting_time'
I found it was the data error , no comma char between 2 lines, maybe produced when saving result to csv file :
def save_csv(self, out_csv_name, episode):
"""Save metrics of the simulation to a .csv file.
Args:
out_csv_name (str): Path to the output .csv file. E.g.: "results/my_results
episode (int): Episode number to be appended to the output file name.
"""
if out_csv_name is not None:
df = pd.DataFrame(self.metrics)
Path(Path(out_csv_name).parent).mkdir(parents=True, exist_ok=True)
df.to_csv(out_csv_name + f"_conn{self.label}_ep{episode}" + ".csv", index=False)
Are you using Windows, @sitexa ? This error does not occur for me
Are you using Windows, @sitexa ? This error does not occur for me
Sometime happen sometime not, depends on the data, maybe empty or null fields. MacOS.
Are you using Windows, @sitexa ? This error does not occur for me
Sometime happen sometime not, depends on the data, maybe empty or null fields. MacOS.
Also on Ubuntu, there were data format error, every run.
Please take a look at the csv file: ppo_conn0_ep2.csv
@LucasAlegre
Was this already fixed in the last commit? @sitexa
Was this already fixed in the last commit? @sitexa
Not yet. It's the same error, data error in ppo_conn0_ep2.csv, when run plot.py.
TypeError: Could not convert 0.81648920.0 to numeric
I solved the problem temporary by changing the plot.py code:
df = pd.read_csv(f, sep=args.sep, on_bad_lines="skip", usecols=[args.xaxis, args.yaxis], converters={args.xaxis: convert_to_float, args.yaxis: convert_to_float})
where convert_to_float
is as bellow:
def convert_to_float(x) -> float:
try:
return float(x)
except:
return float(0)
I got bad result when running
python experiments/ppo_4x4grid.py
,outputs/4x4grid/ppo_conn0_ep2.cvs
: So, when run python outputs/plot.py -f -f outputs/4x4grid/ppo_conn0_ep2.cvs, exceptions were raised out.My environment is as following:
Can anyone get rid of this error? Thanks.