join two dataframes on common column

后端 未结 2 1539
轮回少年
轮回少年 2020-12-07 05:42

I want to join two data sources, orders and customers:

orders is an SQL Server table:

orderid| customerid | orderdate | ordercost
------ | ----------         


        
2条回答
  •  被撕碎了的回忆
    2020-12-07 05:57

    empty dataframe result for pd.merge means you don't have any matching values across the two frames. Have you checked the type of the the data? use

    df1['customerid'].dtype
    

    to check.

    as well as converting after importing (as suggested in the other answer), you can also tell pandas what dtype you want when you read the csv

    df2=pd.read_csv(customer_csv, dtype={'customerid': str))
    

提交回复
热议问题