Data Visualization and EDA Lab Problem 6
Здравейте,
Идеята ми е да разкарам US и от новия dataframe да си дръпна max-a groupby по size за native_country.
income_data.native_country[income_data.groupby('native_country').size().max()]
=> резултат
'United-States'
new_income_data = income_data[~income_data.native_country.str.contains
('United-States')]
new_income_data.native_country[new_income_data.groupby('native_country').size().max()]
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-337-9414f069507f> in <module> ----> 1 new_income_data.native_country[new_income_data.groupby('native_country').size().max()] ~\Anaconda3\lib\site-packages\pandas\core\series.py in __getitem__(self, key) 866 key = com.apply_if_callable(key, self) 867 try: --> 868 result = self.index.get_value(self, key) 869 870 if not is_scalar(result): ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_value(self, series, key) 4373 try: 4374 return self._engine.get_value(s, k, -> 4375 tz=getattr(series.dtype, 'tz', None)) 4376 except KeyError as e1: 4377 if len(self) > 0 and (self.holds_integer() or self.is_boolean()): pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() KeyError: 643
Бих бил благодарен за предложения/насоки.