Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.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 在dataframe中指定productID时如何返回特定的审阅数据_Python_Pandas_Dataframe - Fatal编程技术网

Python 在dataframe中指定productID时如何返回特定的审阅数据

Python 在dataframe中指定productID时如何返回特定的审阅数据,python,pandas,dataframe,Python,Pandas,Dataframe,我正在尝试返回特定productID的审阅数据。我已成功返回多个具有以下语法的列: #display productID and review text df1 = df[['asin', 'reviewText']] #display all orders with specific ASIN filtered_data = df[df["asin"]== '0739079891'] 我已使用以下语法成功返回给定productID的所有

我正在尝试返回特定productID的审阅数据。我已成功返回多个具有以下语法的列:

    #display productID and review text
    df1 = df[['asin', 'reviewText']] 
    #display all orders with specific ASIN
    filtered_data = df[df["asin"]== '0739079891']
我已使用以下语法成功返回给定productID的所有数据:

    #display productID and review text
    df1 = df[['asin', 'reviewText']] 
    #display all orders with specific ASIN
    filtered_data = df[df["asin"]== '0739079891']
是否可以使用=指定给定的asin(productID)并同时显示与该特定productID关联的reviewText?

用于按掩码和列表中的列名进行筛选:

filtered_data = df.loc[df["asin"]== '0739079891', ['asin', 'reviewText']]

除了上面的答案,我还经常使用df.query。语法:

dfSub = df.query('asin=="0739079891"')[['asin', 'reviewText']]

谢谢你的回复!这正是我要找的!