How to convert the row-wise data of dataframe with its column name as key and row data as value in json using python

后端 未结 3 1253
没有蜡笔的小新
没有蜡笔的小新 2021-01-27 16:16

I am having the issue in converting the row-wise data of dataframe with the column name as key and row data as value. I want to pass this row-wise json to another API a

3条回答
  •  [愿得一人]
    2021-01-27 17:12

    Try this:

    import requests
    import pandas as pd
    def call_api(json_data):
        r = requests.post(url, headers=headers, data=out)
        print(r.json())
    
    df.apply(lambda x:call_api(x.to_json()),axis=1)
    

    Hope this helps!

提交回复
热议问题