Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在dataframe中创建子列并使用python中的pandas添加数据_Python_Pandas - Fatal编程技术网

如何在dataframe中创建子列并使用python中的pandas添加数据

如何在dataframe中创建子列并使用python中的pandas添加数据,python,pandas,Python,Pandas,实际上,我面临着以特定格式在子列中添加数据的问题。我已经创建了“多点”作为主专栏,我想 df["Polypoints"] = [{"__type":"Polygon","coordinates":Row_list}] 其中Row_list是dataframe的列,其中包含以下格式的数据 df["Row_list"] = [[x1,y1],[x2,y2],[x3,y3] [x1,y1],[x2,y2],[x3,y3] [x1,y

实际上,我面临着以特定格式在子列中添加数据的问题。我已经创建了“多点”作为主专栏,我想

df["Polypoints"] = [{"__type":"Polygon","coordinates":Row_list}]
其中Row_list是dataframe的列,其中包含以下格式的数据

df["Row_list"] = [[x1,y1],[x2,y2],[x3,y3]
                 [x1,y1],[x2,y2],[x3,y3]
                 [x1,y1],[x2,y2],[x3,y3]]
我想将数据帧转换为json格式
“多点”:{“\u类型”:“多边形”,“坐标”:行列表}

我已经在数据框列“行列表”中添加了列表。我必须按照上面的规定在数据框中再添加一列“多点”,并在“坐标”子列中添加行列表列的数据。尝试
json
jsonpickle
包。例如,
json.dumps(df)
。基于我提出的与上述答案相关的问题。请检查链接,并建议您尝试
json
类似于上面评论中提出的问题?我觉得这是个不错的选择。。。