'groupedby_obj How to select and use data given under a key
Code:
grouped_object = cov.groupby(["Continent"])
for key, item in grouped_obj:
print('key is: ' + str(key))
Output:
key is: Africa
key is: Asia
key is: Europe
key is: Latin America and the Caribbean
key is: Northern America
key is: Oceania
I want to select data only under Africa for further processing, can any help me out.
Solution 1:[1]
You can use get_group:
africa_data = cov.groupby(["Continent"]).get_group("Africa")
You could also use DataFrame.query:
africa_data = cov.query("Continent == 'Africa'")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim |
