[英]How to group together values in Python?
Try:尝试:
df.loc[df["screen_size"]>=6.0,"brand_name"].value_counts()
(i) df.loc[df["screen_size"]>=6.0,"brand_name"]
is a pandas Series that consists of the rows of the brand_name
column where the corresponding screen_size>=6
(i)
df.loc[df["screen_size"]>=6.0,"brand_name"]
是一个 pandas 系列,由brand_name
列的行组成,其中相应的screen_size>=6
(ii) value_counts()
method counts each brand_name
in that pandas Series. (ii)
value_counts()
方法计算该brand_name
系列中的每个品牌名称。
No need for loc不需要 loc
df2 = df[df["screen_size"]>=6.0]
print(df2.shape)
Maybe try:也许尝试:
print((df.loc["screen_size"]>=6.0).count())
if you want to use loc,Maybe try:如果你想使用 loc,也许可以尝试:
df.loc[:,df["screen_size"]>=6.0]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.