【发布时间】:2019-10-12 00:17:21
【问题描述】:
我有一个要转换为数据框的行列表。列表的每个元素都是 pandas Series 类型。如何转换?
样本数据如下:
GROUP_NUM 61
PID_LOCATION [(-111.58903, 33.252235), (-111.59659, 33.2470...)]
PROJECT_KEYS 224033,20542,224037,224039,224040,224041,16610...
PROJECT_NAME name1...
ZIPCODE xxxxx
DEFAULT_GEOM MULTIPOLYGON (((-111.645291932 33.215893723,-1...
Name: 8468, dtype: object, aoi_attr_type_id
aoi_id ffeaac-cb85-447f-a367-b37558e452
GROUP_NUM 60
PID_LOCATION [(u'-117.40181', u'34.542542')]
PROJECT_KEYS 204222
PROJECT_NAME xyz
ZIPCODE 92xxx
DEFAULT_GEOM MULTIPOLYGON(((-117.416929337 34.557322993,-11...)))
Name: 8469, dtype: object, aoi_attr_type_id
aoi_id ff69ae-d61a-4776-af1d-5da73eb05a
GROUP_NUM 63
PID_LOCATION [(-97.348755, 32.587357), (-97.33046, 32.57823...)]
PROJECT_KEYS 218461,181794,209575,59540,15239
PROJECT_NAME some_name2
ZIPCODE yyyyy
DEFAULT_GEOM MULTIPOLYGON (((-97.332423163 32.571877745,-97...)))
Name: 8470, dtype: object]```
I tried this and get the following error:
ipdb> res_df=pd.DataFrame.from_items(merged_polygons)
*** ValueError: too many values to unpack
FYI
ipdb> type(merged_polygons[0])
<class 'pandas.core.series.Series'>
【问题讨论】:
-
pd.DataFrame(merged_polygons)不起作用吗?其中merged_polygons是pd.Series的列表。