Home > OS >  Pandas merges 2 Collumns into one
Pandas merges 2 Collumns into one

Time:07-21

I successfully can connect and read SharePoint Lists vie the Office 365 Sharepoint REST API in Python. From the for loop I want to bring it into a data frame. Currently I have no idea, why I get a data frame where all Columns are getting combined into one.

Code with Output

CodePudding user response:

You can use a dictionary in for loop and then convert it to pd.DataFrame(dict).

my_dict = {"Spalte":[],"Spalte1":[]}

for item in items:
   my_dict["Spalte"].append(item.properties['Spalte'])
   my_dict["Spalte1"].append(item.properties['Spalte1'])

df = pd.DataFrame(my_dict)

The above method can produce the output you want.

  • Related