eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.44k stars 1.38k forks source link

pandas change of API #12322

Open behrisch opened 1 year ago

behrisch commented 1 year ago

The following FutureWarnings occur:

sumo/tools/import/gtfs/gtfs2osm.py:137: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)`
  extra_stop_times.loc[:, 'arrival_fixed'] = extra_stop_times.loc[:, 'arrival_fixed'] % full_day
sumo/tools/import/gtfs/gtfs2osm.py:138: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)`
  extra_stop_times.loc[:, 'departure_fixed'] = extra_stop_times.loc[:, 'departure_fixed'] % full_day
tools/import/gtfs/gtfs2fcd.py:126: FutureWarning: In a future version of pandas, a length 1 tuple will be returned when iterating over a groupby with a grouper equal to a list of length 1. Don't supply a list with a single grouper to avoid this warning.
  for _, trip_data in full_data_merged.groupby(['route_id']):
tools/import/gtfs/gtfs2fcd.py:128: FutureWarning: In a future version of pandas, a length 1 tuple will be returned when iterating over a groupby with a grouper equal to a list of length 1. Don't supply a list with a single grouper to avoid this warning.
MatteoFel commented 11 months ago

Hi Michael,

The following similar FutureWarnings when running the "get_line_dir" function in gtfs2osm.py:

/opt/homebrew/Cellar/sumo/tools/import/gtfs/gtfs2osm.py:338: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead lat_dif = float(line_dest[1]) - float(line_orig[1]) /opt/homebrew/Cellar/sumo/tools/import/gtfs/gtfs2osm.py:339: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead lon_dif = float(line_dest[0]) - float(line_orig[0])

currently leads to an actual TypeError

Traceback (most recent call last): File "/opt/homebrew/Cellar/sumo/tools/import/gtfs/gtfs2pt.py", line 465, in main(get_options()) File "/opt/homebrew/Cellar/sumo/tools/import/gtfs/gtfs2pt.py", line 410, in main missing_stops, missing_lines) = gtfs2osm.map_gtfs_osm(options, net, osm_routes, gtfs_data, shapes, File "/Users/matteofelder/lib/python3.10/site-packages/sumolib/miscutils.py", line 48, in benchmark_wrapper result = func(*args, **kwargs) File "/opt/homebrew/Cellar/sumo/tools/import/gtfs/gtfs2osm.py", line 546, in map_gtfs_osm line_dir = get_line_dir((pt_orig.shape_pt_lon, pt_orig.shape_pt_lat), File "/opt/homebrew/Cellar/sumo/tools/import/gtfs/gtfs2osm.py", line 338, in get_line_dir lat_dif = float(line_dest[1]) - float(line_orig[1]) File "/Users/matteofelder/lib/python3.10/site-packages/pandas/core/series.py", line 230, in wrapper raise TypeError(f"cannot convert the series to {converter}") TypeError: cannot convert the series to <class 'float'>

Is this something you experienced before?

Thanks a million, Matteo

behrisch commented 11 months ago

No I don't think so but thanks for mentioning it, I will try to solve it as well when tackling this one.