我正在尝试返回特定productID的评论数据。我已经使用以下语法成功地返回了多个列:
#display productID and review text
df1 = df[['asin', 'reviewText']] 我已经成功地返回了给定productID的所有数据,语法如下:
#display all orders with specific ASIN
filtered_data = df[df["asin"]== '0739079891']是否可以使用=指定给定的asin( productID )并显示与该特定productID关联的reviewText?
发布于 2020-09-28 20:40:55
使用DataFrame.loc可按掩码过滤,也可按列表中的列名过滤:
filtered_data = df.loc[df["asin"]== '0739079891', ['asin', 'reviewText']]发布于 2020-09-28 20:48:52
除了上面的答案,我也经常使用df.query。语法:
dfSub = df.query('asin=="0739079891"')[['asin', 'reviewText']]https://stackoverflow.com/questions/64102336
复制相似问题