Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.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,我想打印那些item\u pricefinal介于item\u price1和item\u price2 这里是我正在运行的代码和数据集- import pandas as pd pd.set_option('display.max_columns', None) # Number of columns to be displayed pd.set_option('display.width', None) # Max table width to display pd.set_optio

我想打印那些
item\u pricefinal
介于
item\u price1
item\u price2

这里是我正在运行的代码和数据集-

import pandas as pd

pd.set_option('display.max_columns', None)  # Number of columns to be displayed
pd.set_option('display.width', None)  # Max table width to display
pd.set_option('display.max_rows', None)  # Max number of rows
pd.set_option('mode.chained_assignment', None)  # Turn off SettingWithCopyWarning warning

data_list = <<Please read from here - https://1drv.ms/t/s!Aiw4HhkSppuhET8gSypP?e=y71rot
data_df = pd.DataFrame(data_list)
data_df.columns = ['item_date', 'item_price1', 'item_price2', 'item_pricefinal', 'itempricefinal-itemprice1', 'itempricefinal-itemprice2']
mask = data_df['item_pricefinal'].between(data_df['item_price1'], data_df['item_price2'])
请允许我请求帮助以发现错误?

在中,
左为左边界
右为右边界

在这种情况下,您的示例将起作用

mask = data_df['item_pricefinal'].between(
    data_df['item_price2'], data_df['item_price1'])
在中,
左为左边界
右为右边界

在这种情况下,您的示例将起作用

mask = data_df['item_pricefinal'].between(
    data_df['item_price2'], data_df['item_price1'])

data\u df['item\u pricefinal']之间存在差异。在(a,b)
data\u df['item\u pricefinal']之间存在差异。在(b,a)
之间存在差异。顺序(a,b)或(b,a)很重要

似乎
项目价格2
低于
项目价格1
。所以正确的代码应该是

data_df['item_pricefinal'].between(data_df['item_price2'],data_df['item_price1'])

data\u df['item\u pricefinal']之间存在差异。在(a,b)
data\u df['item\u pricefinal']之间存在差异。在(b,a)
之间存在差异。顺序(a,b)或(b,a)很重要

似乎
项目价格2
低于
项目价格1
。所以正确的代码应该是

data_df['item_pricefinal'].between(data_df['item_price2'],data_df['item_price1'])

系列的第一个参数。between
取下界,第二个参数取上界。从示例数据来看,
itemprice1
似乎大于
itemprice2
,因此在这种情况下,您必须颠倒传递参数的顺序。
Series.between
的第一个参数取下界,第二个参数取上界。从示例数据来看,
itemprice1
似乎大于
itemprice2
,因此在这种情况下,必须颠倒传递参数的顺序。