我有一个要转换为数据框的行列表。列表中的每个元素都是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'>
答案 0 :(得分:0)
从这里找到了这个:https://github.com/pandas-dev/pandas/issues/1494
df = pd.DataFrame.from_items([(s.name, s) for s in merged_polygons]).T
答案 1 :(得分:0)
您可以使用-----------------------
JsonValue
-----------------------
#Sitecore.XConnect.Goal
使其更简单。每个系列将是pd.concat
df
如果要将每个系列都排成df = pd.concat(merged_polygons, axis=1)
,只需添加df
T