1

我的第一个数据帧有两个数据帧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

请注意,添加了新列,第一列和第二列分别命名为“用户”和“关注者”。我试过:

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

你能帮帮我吗?谢谢你。

4

1 回答 1

1

我找到了解决方案;你只需这样做:

EDGE_LIST1 = pandas.concat({'User':start_df_1, 'Follower': friends_df}, axis=1)
于 2013-10-26T20:22:02.943 回答