0

I'm trying to count the occurrences of the same number in a column of a DF. These numbers represent the month of the year:

shoes_uk["Month"].head(10)

105    1
464    3
575    3
583    3
631    3
668    4
701    4
724    4
731    4
737    4
Name: Month, dtype: int64

month_14 = shoes_uk["Month"]

for m in month_14:
    for j in month_14:
        if m == j:
             su += 1
print (su)

The Idea is to have how many occurrences I got in Jan, Feb, Mar, etc. I'm not very good with loops, I've tried different combinations from the above code but I haven't get it yet

Amauri
  • 1
  • This is value counts with a month mapper if needed: `import calendar` , `shoes_uk['Month'].map(dict(enumerate(calendar.month_abbr))).value_counts(sort=False)` – anky Mar 15 '20 at 05:08
  • It worked just great df['Month'].map(dict(enumerate(calendar.month_abbr))).value_counts(sort=False) Out[12]: Feb 228 Nov 205 Aug 302 Mar 210 Oct 265 May 246 Sep 242 Jan 186 Apr 291 Dec 247 Jul 254 Jun 276 Name: Month, dtype: int64 Thank you so much! – Amauri Mar 17 '20 at 00:36

0 Answers0