【发布时间】:2022-11-15 07:04:14
【问题描述】:
我有一个数据集,我需要使用 Python 和 Pandas 在满足特定条件的列中查找特定项目的平均价格。标准是“制造商”栏中的“本田”和“丰田”,“条件”栏中的“良好”,以及“类型”栏中的“轿车”。价格在“价格”栏
我知道我需要使用 groupby() 但我不确定还能做什么
import numpy as np
import pandas as pd
df = pd.read_csv("vehicles.csv")
def get_avg_prices():
df.groupby(['criteria','manufacturer','condition']).['price'].mean
这就是我开始的方式,但不确定从这里去哪里或者这是否正确
【问题讨论】: