简体   繁体   中英

To connect pandas dataframe and dict?

I need to connect dataframe and dict like this the number of each cell is different so the number of "0","1" and so on is different total number of cells 16.

You should try to make some code, but, how about this?

df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
d = {"C": [7, 8, 9], "D": [10, 11, 12]}
df = pd.concat([df, pd.DataFrame(d)], axis=1)
print(df)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM