i need a pandas equivalent to following SQL join which is right now to slow...
# SQL lite solution
import sqlite3
#Make the db in memory
conn = sqlite3.connect(':memory:')
#write the tables
df_weather.to_sql('weather', conn, index=False)
data.to_sql('flights', conn, index=False)
qry = '''
select *
from weather left join flights
ON weather.AIRPORT_IATA = flights.destination
AND flights.scheduled_arrival_time BETWEEN weather.VALID_FROM_TIME AND weather.VALID_TO_TIME
'''
data = pd.read_sql_query(qry, conn)
is there a pandas way to merge two dfs with SQL like above? (using between)
scheduled_arrival_time
, VALID_FROM_TIME
and VALID_TO_TIME
are timestamps.
a simple pandas merge won't work.