Python 获取每个标记的最小最大和平均viewcount
我的数据集是这样的Python 获取每个标记的最小最大和平均viewcount,python,pandas,dataframe,Python,Pandas,Dataframe,我的数据集是这样的 id viewcount title answercount tags first_tag 1 78 ** 2 ** python 2 87 ** 1 ** pandas 3 87 ** 1 ** pandas 4 83 ** 0 ** Excel
id viewcount title answercount tags first_tag
1 78 ** 2 ** python
2 87 ** 1 ** pandas
3 87 ** 1 ** pandas
4 83 ** 0 ** Excel
现在我想得到每个标记python、pandas和dataframe的最小、最大和平均viewcount
我已经建立了单独的数据库,其中第一个标签是python、pandas和dataframe,但我不知道如何获得每个标签的最小最大和平均viewcount。使用
groupby
跟随描述
df.groupby('first_tag').viewcount.describe()
Out[89]:
count mean std min 25% 50% 75% max
first_tag
Excel 1.0 83.0 NaN 83.0 83.0 83.0 83.0 83.0
pandas 2.0 87.0 0.0 87.0 87.0 87.0 87.0 87.0
python 1.0 78.0 NaN 78.0 78.0 78.0 78.0 78.0
@Wem Ben非常感谢您的帮助,但是您能告诉我如何才能在我只需要python和pandas的详细信息而不需要任何其他值的地方获得输出。@BarotShalindf.loc[df.first_tag.isin(['python','pandas'])].groupby('first_tag').viewcount.description()
正是我想要的,非常感谢您的帮助!最后一个问题,你能告诉我groupby函数到底是如何工作的吗?@BarotShalin,你可以问一下