Вы можете попробовать следующее:
import pandas as pd
df1 = pd.read_csv("file.csv")
df2 = pd.read_csv("file2.csv")
df2['C'] = pd.to_datetime(df2['C'], format='%Y-%m-%d')
dates = []
for ind in df2.index:
if(df2['D'][ind]>2):
date_tup = (df2['C'][ind].year,df2['C'][ind].month,df2['C'][ind].day)
dates.append(date_tup)
df1['A'] = pd.to_datetime(df1['A'], format='%Y-%m-%d', errors='ignore')
for ind in df1.index:
date_tup = (df1['A'][ind].year,df1['A'][ind].month,df1['A'][ind].day)
if(date_tup not in dates):
df1 = df1.drop([ind])
print(df1)
file1.csv:
A,B
2019-01-01 03:56:29,197.199997
2019-01-01 04:02:29,197.186142
2019-01-02 06:24:29,196.857986
2019-01-02 06:42:29,196.816376
2019-01-03 11:52:29,196.100006
2019-01-03 12:00:30,196.015961
2019-01-04 14:18:30,194.566376
2019-01-04 14:38:30,194.356293
2019-01-04 19:48:30,191.100006
2019-01-05 19:56:30,191.081512
file2.csv:
C,D
2019-01-01 18:00:00,1333
2019-01-02 19:00:00,1.18
2019-01-03 20:00:00,1666667
2019-01-04 21:00:00,0
2019-01-05 22:00:00,1
2019-01-06 23:00:00,1.5
2019-01-07 00:00:00,109
2019-01-08 01:00:00,200
2019-01-09 02:00:00,192
2019-01-10 03:00:00,1.700000