I'm grouping dataframe by 2 groups native-country
and salary
, but output on hours-per-week
is too large to find specific country.
df.groupby(by=['native-country', 'salary'])['hours-per-week']
How to select group by country name, eg 'Japan' ?
Why are you using a groupby
at all if you're not trying to perform any aggregations/transformations? Just do:
df.query("'native-country' == 'Japan'")\
.loc[:, ["native_country", "salary", "hours-per-week"]]
newdf = ddf.groupby('country').**size()/all()/count()/...**
result = newdf.filter(lambda x : True if x.country == 'japan' else False)lt
print result
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.