table_norm = ncs_good['CountryLive'].value_counts(normalize = True) table_abs = ncs_good['CountryLive'].value_counts() print(table_norm[:5]) print('\n') print(table_abs[:5]) other_norm = table_norm[5:].sum() table_other = pd.Series['Other', other_norm] table_norm.append(table_other) table_norm
What I expected to happen:
So the idea of the whole thing was to create a row in table_norm which would contain the sum of all the locations that are not part of the top 5 and assign then to “Others” so my pie chart would be easier to read. This is probably not one of the clever ways to go about this, but it was what I could think till now, if anyone has a better solution than this one or knows how to fix this bug, I would gladly hear it out.
What actually happened:
TypeErrorTraceback (most recent call last) <ipython-input-17-554afa05234c> in <module>() 1 other_norm = table_norm[5:].sum() ----> 2 table_other = pd.Series['Other', other_norm] 3 table_norm.append(table_other) 4 table_norm TypeError: 'type' object is not subscriptable