Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.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_Pandas_Dataframe - Fatal编程技术网

Python 熊猫:如何确定一个表中的数据是否在第二个表的范围内

Python 熊猫:如何确定一个表中的数据是否在第二个表的范围内,python,pandas,dataframe,Python,Pandas,Dataframe,我们在一天内下了两份订单: 以及使用所有应用程序的时间 问题:给定从第一个表到下订单的时间,我们如何确定第二个表中的时间段 您可以为每个订单确定当时使用的应用程序。显然,当时可能有多个应用程序在运行。假设您的订单存储在名为order\u df的数据框中,应用程序信息存储在另一个名为application\u df的数据框中。然后,您可以循环所有订单,并检查正在运行的应用程序(将结果存储在dict中): order_-map={} 对于ix,它的顺序为_df.iterrows(): order

我们在一天内下了两份订单:

以及使用所有应用程序的时间


问题:给定从第一个表到下订单的时间,我们如何确定第二个表中的时间段

您可以为每个订单确定当时使用的应用程序。显然,当时可能有多个应用程序在运行。假设您的订单存储在名为
order\u df
的数据框中,应用程序信息存储在另一个名为
application\u df
的数据框中。然后,您可以循环所有订单,并检查正在运行的应用程序(将结果存储在dict中):

order_-map={}
对于ix,它的顺序为_df.iterrows():
order\u id=it['OrderId']
订单时间=它['time']
条件=(应用程序时间['StartTime']=订单时间)
订单映射[order\u id]=application\u df[condition]['ApplicationID']

不要将数据帧和代码发布为图像。在你的问题中以文本的形式发布。好的,下次将发布没有图片的内容。谢谢你的建议:)
order_map = {}
for ix, it in order_df.iterrows():
    order_id = it['OrderId']
    order_time = it['Time']
    condition = (application_df['StartTime'] <= order_time) & (application_df['EndTime'] >= order_time)
    order_map[order_id] = application_df[condition]['ApplicationID'].values