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
,因此在这种情况下,必须颠倒传递参数的顺序。