I usually try (and manage ) to answer the questions while avoiding for loops and df.apply(). This time however, while my method produces an answer that looks identical to the requested output,it is not accepted by the answer checker. Any thoughts as to why this is happening?
The indexes are different, actually. Try printing both indexes and see what they look like. Donโt just go about what you see when you look at the series object โ print("10") and print(10) display indistinguishable output.
The following code should fix your solution.
wnba = pd.read_csv('wnba.csv')
intervals = pd.interval_range(start = 0, end = 600, freq = 60)
gr_freq_table_10 = pd.cut(wnba.PTS, intervals).to_frame().groupby("PTS").size()
gr_freq_table_10.index = pd.Series([0 for _ in range(10)], index = intervals).index
Ah brilliant, thanks! Having gone back and checked pd.cut() docs, they do mention it returns a categorical.
FWIW, inspired by your solution and the fact that pd.interval_range() already returns a IntervaIndex object, I found that this works just as well: