简体   繁体   中英

Matching dates between two dataframes in pandas

In Pandas, I have two dataframes, both with dates.

One dataframe contains about 100000 dates and the other about 7000 dates.

How do I keep the dates in dataframe1 that matches the dates with dataframe2?

You can do an inner join operation. Since you only want data that exists in both dataframes.

在此处输入图片说明

Since you did not paste much about your code, I will provide a bit of a pseudo-example:

pd.merge(left=df_with_millions, left_on='date_column',
         right=df_with_seven_thousand, right_on='date_column')

You can read more about merging here: http://pandas.pydata.org/pandas-docs/stable/merging.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM