colors.csv
id name rgb is_trans
0 -1 Unknown 0033B2 f
1 0 Black 05131D f
2 1 Blue 0055BF t
您如何计算f&t的数量(如下所示)
colors_summary = colors.count('is_trans')
print(colors_summary)
寻找结果
is_trans id name rgb
f 107 107 107
t 28 28 28
答案 0 :(得分:1)
假设您有
color_df # dataframe object
您可以这样做:
result_df = color_df.groupby('is_trans').count()
print(result_df) # should give you what you ask for.
答案 1 :(得分:0)
和stdlib ?- count([3,4,5,6],C).
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [8] count([3,4|...],_972)
ERROR: [7] <user>
的替代方案。
csv & Counter