I am practising boolean indexing in pandas intro section " Exploring Data with pandas: Fundamentals" and I’m at the end of the task where the instructions are to " Create a series,
industry_usa , containing counts of the two most common values in the
industry column for companies headquartered in the USA".
the correct code is apparently
industry_usa = f500['industry'][f500['country'] == 'USA'].value_counts().head(2) sector_china = f500["sector"][f500["country"] == "China"].value_counts().head(3)
There has been no example where we use indexing as described above.
Why can we suddenly use series one after the other i.e f500[‘industry’][f500[‘country’]. The back to back series calling is something I didn’t know we could do. Could someone please explain why this works?
Thank you in advance
P.S I’m very new to this.