Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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
Python正在折叠一个;熊猫.核心.系列.系列“;从映射调用转换为数据帧_Python_Pandas_Dataframe - Fatal编程技术网

Python正在折叠一个;熊猫.核心.系列.系列“;从映射调用转换为数据帧

Python正在折叠一个;熊猫.核心.系列.系列“;从映射调用转换为数据帧,python,pandas,dataframe,Python,Pandas,Dataframe,我是python新手,希望有人能帮助我掌握map。 我有一个函数myfunc,它在一个数据帧中获取一列,并为每一列创建一个计算,从而生成一个JSON,然后将其转换为一个数据帧。下面是我正在做的工作的伪代码 比如说 def myfunc (factor): # This is the API we are posting to str_url = "www.foourl.com" # This is the factor we post to

我是python新手,希望有人能帮助我掌握
map
。 我有一个函数
myfunc
,它在一个数据帧中获取一列,并为每一列创建一个计算,从而生成一个JSON,然后将其转换为一个数据帧。下面是我正在做的工作的伪代码

比如说

def myfunc (factor):
    
    # This is the API we are posting to
    str_url = "www.foourl.com"

    # This is the factor we post to try and get the result
    request_string = [{"foo":factor}]
          
    header = {"content-type": "application/json","AUTH-TOKEN": "Foo"}
    # We post it using our authorization and Token
    response = requests.post(str_url , data=json.dumps(request_string), headers=header)
    
    # convert response to json format and then to the dataframe
    results_json = response.json()
    return(pd.json_normalize(results_json))

然后,我使用下面的代码执行我的函数,这些代码工作得非常好。我可以使用结果[1]访问每个结果,以获得因子[1]的数据帧结果、因子[2]的结果[2],依此类推。它返回一个

我的问题是

由于所有的结果都是数据帧,并且在结构上完全相同(5列都具有相同的名称),有没有一种方法可以在从map进行所有迭代之后将所有内容折叠到一个数据帧中


我知道,例如在
R
中,您可以使用
dplyr
中的bind_行或类似
map_df
的内容来执行相同的操作。它们在python中是等价物吗?

pandas
中是的,我们有
concat

df=pd.concat(result.tolist())
df=pd.concat(result.tolist())