Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫在两个日期之间连接数据_Python_Sql_Pandas - Fatal编程技术网

Python 熊猫在两个日期之间连接数据

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连接,这是现在放缓

# 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
。同样,您可以考虑向左加入或筛选。