Python 熊猫在两个日期之间连接数据
我需要一个相当于下面的SQL连接,这是现在放缓Python 熊猫在两个日期之间连接数据,python,sql,pandas,Python,Sql,Pandas,我需要一个相当于下面的SQL连接,这是现在放缓 # 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
# 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)
有没有一种方法可以像上面那样用SQL合并两个dfs?(在中间使用)
预定到达时间
、有效起始时间
和有效终止时间
都是时间戳
简单的熊猫合并不起作用。请提供一个副本。可能的副本如上所述。如果有内存/速度问题,你可以考虑使用<代码> DASK < /代码>我请求一个熊猫的方式。在可能的复制中,没有明确的方法。也许现在有办法了?嗨@Bernouy,首先如果你能提供一个。然后我建议的答案是使用pandas和AFAIK,没有办法直接将您的查询转换为
pandas
。同样,您可以考虑向左加入或筛选。