Pandas: How can I merge two dataframes? [on hold]











up vote
2
down vote

favorite
1












I found (How do I merge two data frames in Python Pandas?), but do not get the expected result.



I have these two CSV files:



# f1.csv
num ano
76971 1975
76969 1975
76968 1975
76966 1975
76964 1975
76963 1975
76960 1975


and



# f2.csv
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100


How do I merge these for to get the result given below?



# Expected result
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76969 1975
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100
76964 1975
76963 1975
76960 1975









share|improve this question









New contributor




britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question does not appear to be about data science, within the scope defined in the help center." – Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen

If this question can be reworded to fit the rules in the help center, please edit the question.













  • There are many example on StackOverflow
    – Aditya
    2 days ago












  • @Aditya, no how i need. And i newer...
    – britodfbr
    2 days ago










  • What do you mean by "but not assert expected result"? Can you elaborate?
    – Peter Mortensen
    2 days ago










  • Down vote because this is a trivial question. See SO for numerous posts similar to this.
    – Jon
    2 days ago















up vote
2
down vote

favorite
1












I found (How do I merge two data frames in Python Pandas?), but do not get the expected result.



I have these two CSV files:



# f1.csv
num ano
76971 1975
76969 1975
76968 1975
76966 1975
76964 1975
76963 1975
76960 1975


and



# f2.csv
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100


How do I merge these for to get the result given below?



# Expected result
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76969 1975
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100
76964 1975
76963 1975
76960 1975









share|improve this question









New contributor




britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question does not appear to be about data science, within the scope defined in the help center." – Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen

If this question can be reworded to fit the rules in the help center, please edit the question.













  • There are many example on StackOverflow
    – Aditya
    2 days ago












  • @Aditya, no how i need. And i newer...
    – britodfbr
    2 days ago










  • What do you mean by "but not assert expected result"? Can you elaborate?
    – Peter Mortensen
    2 days ago










  • Down vote because this is a trivial question. See SO for numerous posts similar to this.
    – Jon
    2 days ago













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I found (How do I merge two data frames in Python Pandas?), but do not get the expected result.



I have these two CSV files:



# f1.csv
num ano
76971 1975
76969 1975
76968 1975
76966 1975
76964 1975
76963 1975
76960 1975


and



# f2.csv
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100


How do I merge these for to get the result given below?



# Expected result
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76969 1975
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100
76964 1975
76963 1975
76960 1975









share|improve this question









New contributor




britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I found (How do I merge two data frames in Python Pandas?), but do not get the expected result.



I have these two CSV files:



# f1.csv
num ano
76971 1975
76969 1975
76968 1975
76966 1975
76964 1975
76963 1975
76960 1975


and



# f2.csv
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100


How do I merge these for to get the result given below?



# Expected result
num ano dou url
76971 1975 p1 http://exemplo.com/page1
76969 1975
76968 1975 p2 http://exemplo.com/page10
76966 1975 p2 http://exemplo.com/page100
76964 1975
76963 1975
76960 1975






pandas






share|improve this question









New contributor




britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Stephen Rauch

1,30351128




1,30351128






New contributor




britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









britodfbr

1163




1163




New contributor




britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






britodfbr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question does not appear to be about data science, within the scope defined in the help center." – Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question does not appear to be about data science, within the scope defined in the help center." – Stephen Rauch, Siong Thye Goh, n1k31t4, Sean Owen

If this question can be reworded to fit the rules in the help center, please edit the question.












  • There are many example on StackOverflow
    – Aditya
    2 days ago












  • @Aditya, no how i need. And i newer...
    – britodfbr
    2 days ago










  • What do you mean by "but not assert expected result"? Can you elaborate?
    – Peter Mortensen
    2 days ago










  • Down vote because this is a trivial question. See SO for numerous posts similar to this.
    – Jon
    2 days ago


















  • There are many example on StackOverflow
    – Aditya
    2 days ago












  • @Aditya, no how i need. And i newer...
    – britodfbr
    2 days ago










  • What do you mean by "but not assert expected result"? Can you elaborate?
    – Peter Mortensen
    2 days ago










  • Down vote because this is a trivial question. See SO for numerous posts similar to this.
    – Jon
    2 days ago
















There are many example on StackOverflow
– Aditya
2 days ago






There are many example on StackOverflow
– Aditya
2 days ago














@Aditya, no how i need. And i newer...
– britodfbr
2 days ago




@Aditya, no how i need. And i newer...
– britodfbr
2 days ago












What do you mean by "but not assert expected result"? Can you elaborate?
– Peter Mortensen
2 days ago




What do you mean by "but not assert expected result"? Can you elaborate?
– Peter Mortensen
2 days ago












Down vote because this is a trivial question. See SO for numerous posts similar to this.
– Jon
2 days ago




Down vote because this is a trivial question. See SO for numerous posts similar to this.
– Jon
2 days ago










1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted










f1.merge(f2, left_on='num', right_on='num', how='outer')



see https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html






share|improve this answer








New contributor




wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2




    very thanks! I finish below: a1975.merge(b1975, left_on=['num', 'ano'], right_on=['num', 'ano'], how='outer', sort=True)
    – britodfbr
    2 days ago




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote



accepted










f1.merge(f2, left_on='num', right_on='num', how='outer')



see https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html






share|improve this answer








New contributor




wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2




    very thanks! I finish below: a1975.merge(b1975, left_on=['num', 'ano'], right_on=['num', 'ano'], how='outer', sort=True)
    – britodfbr
    2 days ago

















up vote
5
down vote



accepted










f1.merge(f2, left_on='num', right_on='num', how='outer')



see https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html






share|improve this answer








New contributor




wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2




    very thanks! I finish below: a1975.merge(b1975, left_on=['num', 'ano'], right_on=['num', 'ano'], how='outer', sort=True)
    – britodfbr
    2 days ago















up vote
5
down vote



accepted







up vote
5
down vote



accepted






f1.merge(f2, left_on='num', right_on='num', how='outer')



see https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html






share|improve this answer








New contributor




wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









f1.merge(f2, left_on='num', right_on='num', how='outer')



see https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html







share|improve this answer








New contributor




wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 2 days ago









wl1234

663




663




New contributor




wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






wl1234 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    very thanks! I finish below: a1975.merge(b1975, left_on=['num', 'ano'], right_on=['num', 'ano'], how='outer', sort=True)
    – britodfbr
    2 days ago
















  • 2




    very thanks! I finish below: a1975.merge(b1975, left_on=['num', 'ano'], right_on=['num', 'ano'], how='outer', sort=True)
    – britodfbr
    2 days ago










2




2




very thanks! I finish below: a1975.merge(b1975, left_on=['num', 'ano'], right_on=['num', 'ano'], how='outer', sort=True)
– britodfbr
2 days ago






very thanks! I finish below: a1975.merge(b1975, left_on=['num', 'ano'], right_on=['num', 'ano'], how='outer', sort=True)
– britodfbr
2 days ago





Popular posts from this blog

數位音樂下載

When can things happen in Etherscan, such as the picture below?

格利澤436b