我有两个数据框
我的第一个数据框start_df_1
如下所示:
start_df_1
0
0 3Degrees_Inc
1 3Degrees_Inc
2 3Degrees_Inc
3 3Degrees_Inc
4 3Degrees_Inc
5 3Degrees_Inc
6 3Degrees_Inc
7 3Degrees_Inc
8 3Degrees_Inc
9 3Degrees_Inc
10 3Degrees_Inc
我的第二个数据框friends_df
如下所示:
friends_df
0
0 MEGreenPower
1 LympheDIVAs
2 Ecopreneurist
3 issielapowsky
4 NatureClimate
5 miketuritzin
6 greenbang
7 GoodCleanTech
8 EDFbiz
9 adavies47
10 petedanko
我正在尝试创建一个新的数据框,例如:
concatenated_df
User Follower
0 MEGreenPower 3Degrees_Inc
1 LympheDIVAs 3Degrees_Inc
2 Ecopreneurist 3Degrees_Inc
3 issielapowsky 3Degrees_Inc
4 NatureClimate 3Degrees_Inc
5 miketuritzin 3Degrees_Inc
6 greenbang 3Degrees_Inc
7 GoodCleanTech 3Degrees_Inc
8 EDFbiz 3Degrees_Inc
9 adavies47 3Degrees_Inc
10 petedanko1 3Degrees_Inc
请注意添加了新列,第一列和第二列分别命名为“User”和“Follower”。 我试过了:
EDGE_LIST1 = pandas.DataFrame.from_dict({'User':friends_df,
'Follower': start_df_1}, orient='columns')
然而,它给我一个错误:
ValueError: If using all scalar values, you must must pass an index
你可以帮帮我吗?谢谢。
答案 0 :(得分:1)
我找到了解决方案;你这样做:
EDGE_LIST1 = pandas.concat({'User':start_df_1, 'Follower': friends_df}, axis=1)