Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
168 views
in Technique[技术] by (71.8m points)

python - pd.merge is not merging on column values

I am trying to merge these 2 dataframes below on the column retweeting_id

                retweeting_id           retweeting_username     retweeting_followers_count
207857          822215673812119553      WhiteHouse              26139914
        id                      user_id  retweet_count      tweet                              prediction   retweeting_id   username    
4682    1341442941642928129     64932923    191     RT @WhiteHouse: Over 80% of Americans say they...   2   8.222157e+17    Erika   
4683    1341443049067479041     64932923    332     Hope—and help—are on the way!

"The first sh...   2   8.222157e+17    Erika   
5764    1339008184997064705     232598875   694     "Yesterday, the United States witnessed a medi...   1   8.222157e+17    Wm R Collie IV MD   
10065   1338931792800325634     1105109168  297     "Yesterday, the United States witnessed a medi...   1   8.222157e+17    President-elect ?????????????????? ????????     

but when I use

df1 = pd.merge(test2, test1, on= 'retweeting_id')

I get an empty dataframe. I think the scientific notation in the second dataframe is messing it up but I know the numbers are the same because I'm using

test2 = df_merge2[(df_merge2['retweeting_id'] == 822215673812119553  )]

to get the second dataframe. Any ideas on how to get these two to merge, any help would be appreciated. Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try to change the retweeting_id to an integer on the second data frame. Then, try to merge again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...