Поиск по блогу

воскресенье, 29 марта 2015 г.

Ищем команды для проверки, чистки и конвертации столбцов в числовой формат

Здесь я попробовал методы для проверки одородности таблиц и чистки столбцов .describe() .str.contains('%') .replace('%','').get .replace('%','').astype(int) .index.value_counts()
Как-то все трудно шло, отчасти потому, что не могу понять принципов построения методов. Например, долго искал, как превести столбец в числовой формат, оказалось все очень просто .astype(int)

In [1]:
# The usual preamble
%matplotlib inline

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

# Make the graphs a bit prettier, and bigger
pd.set_option('display.mpl_style', 'default')
plt.rcParams['figure.figsize'] = (15, 5)
In [2]:
from StringIO import StringIO
In [3]:
aprpath000 = '/media/MYLINUXLIVE/Documents/Xpdf/aerbu_2014_all_csv/1aug2/000_eng_car-sales-in-april-2014.csv'
In [10]:
pd000 = pd.read_csv(aprpath000, error_bad_lines=False)
pd000
Out[10]:
2014 2013 YoY % 2014.1 2013.1 YoY %.1 Unnamed: 6
Lada 128633 151527 -15% 37030 44100 -16% NaN
Renault* 63647 67208 -5% 17395 19178 -9% NaN
KIA 60033 60027 0% 17744 18303 -3% NaN
Nissan* 57579 44188 30% 11835 8272 43% NaN
Hyundai* 57240 56582 1% 15933 15868 0% NaN
Toyota* 50160 44610 12% 15103 15278 -1% NaN
Chevrolet 48586 52489 -7% 13279 16083 -17% NaN
VW 45828 49477 -7% 11497 14203 -19% NaN
Mitsubishi 27943 26322 6% 6101 7182 -15% NaN

1. Чтобы узнать количество ненулевых ячеек в каждом столбце, надо настроить .info()

In [9]:
pd000.info(verbose=True, buf=None, max_cols=None, memory_usage=True, null_counts=True)
<class 'pandas.core.frame.DataFrame'>
Index: 9 entries, Lada to Mitsubishi
Data columns (total 7 columns):
2014          9 non-null int64
2013          9 non-null int64
YoY %         9 non-null object
2014.1        9 non-null int64
2013.1        9 non-null int64
YoY %.1       9 non-null object
Unnamed: 6    0 non-null float64
dtypes: float64(1), int64(4), object(2)
memory usage: 468.0+ bytes

verbose : {None, True, False}, optional

Whether to print the full summary. None follows the display.max_info_columns setting. True or False overrides the display.max_info_columns setting.

buf : writable buffer, defaults to sys.stdout

max_cols : int, default None

Determines whether full summary or short summary is printed. None follows the display.max_info_columns setting.

memory_usage : boolean, default None

Specifies whether total memory usage of the DataFrame elements (including index) should be displayed. None follows the display.memory_usage setting. True or False overrides the display.memory_usage setting. Memory usage is shown in human-readable units (base-2 representation).

null_counts : boolean, default None

Whether to show the non-null counts If None, then only show if the frame is smaller than max_info_rows and max_info_columns. If True, always show counts. If False, never show counts.
In [28]:
pd000.describe()
Out[28]:
2014 2013 2014.1 2013.1 Unnamed: 6
count 9.000000 9.000000 9.000000 9.000000 0
mean 59961.000000 61381.111111 16213.000000 17607.444444 NaN
std 27822.781511 35727.949516 8592.638666 10741.348311 NaN
min 27943.000000 26322.000000 6101.000000 7182.000000 NaN
25% 48586.000000 44610.000000 11835.000000 14203.000000 NaN
50% 57240.000000 52489.000000 15103.000000 15868.000000 NaN
75% 60033.000000 60027.000000 17395.000000 18303.000000 NaN
max 128633.000000 151527.000000 37030.000000 44100.000000 NaN

Я настолько привык к автоматическому переопределению типов, что надеюся убрать знак % в столбцах "YoY % " и посчитать описания для всех столбцов

In [31]:
pd000['YoY %'].str.contains('%') #p.210 | Chapter 7: Data Wrangling: Clean, Transform, Merge, Reshape
Out[31]:
Lada          True
Renault*      True
KIA           True
Nissan*       True
Hyundai*      True
Toyota*       True
Chevrolet     True
VW            True
Mitsubishi    True
Name: YoY %, dtype: bool

Строковые операторы можно применять ко всему столбцу сразу (Series)

In [38]:
pstr = pd000['YoY %'].str

Пробуем убрать из столбца "лишние символы" при помощи .replace()

In [41]:
pstr.replace('%','').describe()
Out[41]:
count      9
unique     8
top       -7
freq       2
Name: YoY %, dtype: object

Теперь я хотел бы конвертировать столбец строк в столбец чисел (чтобы посчитать средние, например)

In [43]:
dir(pstr)
Out[43]:
['__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__getitem__',
 '__hash__',
 '__init__',
 '__iter__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_wrap_result',
 'cat',
 'center',
 'contains',
 'count',
 'decode',
 'encode',
 'endswith',
 'extract',
 'findall',
 'get',
 'get_dummies',
 'join',
 'len',
 'lower',
 'lstrip',
 'match',
 'pad',
 'repeat',
 'replace',
 'rstrip',
 'series',
 'slice',
 'slice_replace',
 'split',
 'startswith',
 'strip',
 'title',
 'upper',
 'wrap']

Сначала попробуем тупой вариант, здесь срабатывают все варианты для... Так что пока не пойму, конвертирует ли Pandas автоматически, очевидно, что для строковых объектов, вряд ли:

In [47]:
#pstr = pd000['YoY %'].str - мы сами задали объект, как строку
pstr.mean
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-47-0e2c06e6140f> in <module>()
      1 #pstr = pd000['YoY %'].str
----> 2 pstr.mean

AttributeError: 'StringMethods' object has no attribute 'mean'

Так как конвертировать строку в число?

In [48]:
pd000
Out[48]:
2014 2013 YoY % 2014.1 2013.1 YoY %.1 Unnamed: 6
Lada 128633 151527 -16% 37030 44100 -16% NaN
Renault* 63647 67208 -5% 17395 19178 -9% NaN
KIA 60033 60027 0% 17744 18303 -3% NaN
Nissan* 57579 44188 30% 11835 8272 43% NaN
Hyundai* 57240 56582 1% 15933 15868 0% NaN
Toyota* 50160 44610 12% 15103 15278 -1% NaN
Chevrolet 48586 52489 -7% 13279 16083 -17% NaN
VW 45828 49477 -7% 11497 14203 -19% NaN
Mitsubishi 27943 26322 6% 6101 7182 -15% NaN
In [56]:
pstr.replace('%','').get
Out[56]:
<bound method Series.get of Lada          -16
Renault*       -5
KIA             0
Nissan*        30
Hyundai*        1
Toyota*        12
Chevrolet      -7
VW             -7
Mitsubishi      6
Name: YoY %, dtype: object>
In [60]:
pstr.replace('%','').astype(int)
Out[60]:
Lada         -16
Renault*      -5
KIA            0
Nissan*       30
Hyundai*       1
Toyota*       12
Chevrolet     -7
VW            -7
Mitsubishi     6
Name: YoY %, dtype: int32

Вот он, приемлемый вариант для конвертации .astype(int)

2. Чтобы проверить уникальность значений в столбце используем .value_counts()

Здесь мы проверяем столбец индекса. Он у нас по умолчанию получился и соответствует названиям марок. Напомним, что в предыдущем посте мы работали с полным файлом, в котором строка "Mersedes-Benz van" содержала 9 полей (а все 8) и кроме того, была еще строка "Mersedes-Benz"... что с ними делать... еще не решено.

In [14]:
pd000.index.value_counts()
Out[14]:
Hyundai*      1
Mitsubishi    1
KIA           1
Nissan*       1
VW            1
Lada          1
Toyota*       1
Chevrolet     1
Renault*      1
dtype: int64

Очевидно, что подсчет уникальных значений не панацея..., но его рекомендуют авторы мануалов (ссылки в начале поста)

Теперь подсчитаем уникальные значения в обычном столбце:

In [19]:
pd000['YoY %'].value_counts()
Out[19]:
-7%     2
6%      1
30%     1
0%      1
12%     1
1%      1
-15%    1
-5%     1
dtype: int64

Или вот так: .unique()

In [21]:
pd000['YoY %'].unique()
Out[21]:
array(['-15%', '-5%', '0%', '30%', '1%', '12%', '-7%', '6%'], dtype=object)
In [ ]:
####Из столбца можно выбрать конкретный элемент по индексу
In [22]:
column = pd000['YoY %']
In [24]:
column.Lada
Out[24]:
'-15%'
In [25]:
pd000['YoY %'].Lada
Out[25]:
'-15%'
In [26]:
pd000['YoY %'].Lada = '-16%'
/usr/local/lib/python2.7/dist-packages/pandas/core/generic.py:1974: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self[name] = value
In [27]:
pd000['YoY %'].Lada
Out[27]:
'-16%'

Значения "ячейке" можно переприсвоить.

In [ ]:
 
In [ ]:
aprpath = '/media/MYLINUXLIVE/Documents/Xpdf/aerbu_2014_all_csv/1aug2/eng_car-sales-in-april-2014.csv'
In [ ]:
# 
#pd = pd.read_csv(aprpath, error_bad_lines=False)
pd

Методы для обработки столбца

In [23]:
dir(column)
Out[23]:
['Chevrolet',
 'KIA',
 'Lada',
 'Mitsubishi',
 'T',
 'VW',
 '_AXIS_ALIASES',
 '_AXIS_IALIASES',
 '_AXIS_LEN',
 '_AXIS_NAMES',
 '_AXIS_NUMBERS',
 '_AXIS_ORDERS',
 '_AXIS_REVERSED',
 '_AXIS_SLICEMAP',
 '__abs__',
 '__add__',
 '__and__',
 '__array__',
 '__array_prepare__',
 '__array_priority__',
 '__array_wrap__',
 '__bool__',
 '__bytes__',
 '__class__',
 '__contains__',
 '__delattr__',
 '__delitem__',
 '__dict__',
 '__dir__',
 '__div__',
 '__doc__',
 '__eq__',
 '__finalize__',
 '__float__',
 '__floordiv__',
 '__format__',
 '__ge__',
 '__getattr__',
 '__getattribute__',
 '__getitem__',
 '__getstate__',
 '__gt__',
 '__hash__',
 '__iadd__',
 '__idiv__',
 '__imul__',
 '__init__',
 '__int__',
 '__invert__',
 '__ipow__',
 '__isub__',
 '__iter__',
 '__itruediv__',
 '__le__',
 '__len__',
 '__long__',
 '__lt__',
 '__mod__',
 '__module__',
 '__mul__',
 '__ne__',
 '__neg__',
 '__new__',
 '__nonzero__',
 '__or__',
 '__pow__',
 '__radd__',
 '__rand__',
 '__rdiv__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__rfloordiv__',
 '__rmod__',
 '__rmul__',
 '__ror__',
 '__rpow__',
 '__rsub__',
 '__rtruediv__',
 '__rxor__',
 '__setattr__',
 '__setitem__',
 '__setstate__',
 '__sizeof__',
 '__str__',
 '__sub__',
 '__subclasshook__',
 '__truediv__',
 '__unicode__',
 '__weakref__',
 '__xor__',
 '_add_numeric_operations',
 '_agg_by_level',
 '_align_frame',
 '_align_series',
 '_allow_index_ops',
 '_at',
 '_binop',
 '_box_item_values',
 '_can_hold_na',
 '_check_inplace_setting',
 '_check_is_chained_assignment_possible',
 '_check_setitem_copy',
 '_clear_item_cache',
 '_consolidate_inplace',
 '_construct_axes_dict',
 '_construct_axes_dict_for_slice',
 '_construct_axes_dict_from',
 '_construct_axes_from_arguments',
 '_constructor',
 '_constructor_sliced',
 '_create_indexer',
 '_expand_axes',
 '_from_axes',
 '_get_axis',
 '_get_axis_name',
 '_get_axis_number',
 '_get_axis_resolvers',
 '_get_block_manager_axis',
 '_get_bool_data',
 '_get_cacher',
 '_get_index_resolvers',
 '_get_item_cache',
 '_get_numeric_data',
 '_get_repr',
 '_get_val_at',
 '_get_values',
 '_get_values_tuple',
 '_get_with',
 '_iat',
 '_iget_item_cache',
 '_iloc',
 '_index',
 '_indexed_same',
 '_info_axis',
 '_info_axis_name',
 '_info_axis_number',
 '_init_mgr',
 '_internal_names',
 '_internal_names_set',
 '_is_cached',
 '_is_datelike_mixed_type',
 '_is_mixed_type',
 '_is_numeric_mixed_type',
 '_is_view',
 '_ix',
 '_ixs',
 '_loc',
 '_local_dir',
 '_maybe_box',
 '_maybe_cache_changed',
 '_maybe_update_cacher',
 '_metadata',
 '_needs_reindex_multi',
 '_protect_consolidate',
 '_reduce',
 '_reindex_axes',
 '_reindex_axis',
 '_reindex_indexer',
 '_reindex_multi',
 '_reindex_with_indexers',
 '_repr_footer',
 '_reset_cache',
 '_set_as_cached',
 '_set_axis',
 '_set_is_copy',
 '_set_item',
 '_set_labels',
 '_set_subtyp',
 '_set_values',
 '_set_with',
 '_set_with_engine',
 '_setup_axes',
 '_slice',
 '_stat_axis',
 '_stat_axis_name',
 '_stat_axis_number',
 '_tidy_repr',
 '_typ',
 '_unpickle_series_compat',
 '_update_inplace',
 '_validate_dtype',
 '_xs',
 'abs',
 'add',
 'add_prefix',
 'add_suffix',
 'align',
 'all',
 'any',
 'append',
 'apply',
 'argmax',
 'argmin',
 'argsort',
 'as_blocks',
 'as_matrix',
 'asfreq',
 'asof',
 'astype',
 'at',
 'at_time',
 'autocorr',
 'axes',
 'base',
 'between',
 'between_time',
 'bfill',
 'blocks',
 'bool',
 'cat',
 'clip',
 'clip_lower',
 'clip_upper',
 'combine',
 'combine_first',
 'compound',
 'compress',
 'consolidate',
 'convert_objects',
 'copy',
 'corr',
 'count',
 'cov',
 'cummax',
 'cummin',
 'cumprod',
 'cumsum',
 'data',
 'describe',
 'diff',
 'div',
 'divide',
 'dot',
 'drop',
 'drop_duplicates',
 'dropna',
 'dt',
 'dtype',
 'dtypes',
 'duplicated',
 'empty',
 'eq',
 'equals',
 'factorize',
 'ffill',
 'fillna',
 'filter',
 'first',
 'first_valid_index',
 'flags',
 'floordiv',
 'from_array',
 'from_csv',
 'ftype',
 'ftypes',
 'ge',
 'get',
 'get_dtype_counts',
 'get_ftype_counts',
 'get_value',
 'get_values',
 'groupby',
 'gt',
 'hasnans',
 'head',
 'hist',
 'iat',
 'idxmax',
 'idxmin',
 'iget',
 'iget_value',
 'iloc',
 'imag',
 'index',
 'interpolate',
 'irow',
 'is_copy',
 'is_time_series',
 'isin',
 'isnull',
 'item',
 'itemsize',
 'iteritems',
 'iterkv',
 'ix',
 'keys',
 'kurt',
 'kurtosis',
 'last',
 'last_valid_index',
 'le',
 'load',
 'loc',
 'lt',
 'mad',
 'map',
 'mask',
 'max',
 'mean',
 'median',
 'min',
 'mod',
 'mode',
 'mul',
 'multiply',
 'nbytes',
 'ndim',
 'ne',
 'nlargest',
 'nonzero',
 'notnull',
 'nsmallest',
 'nunique',
 'order',
 'pct_change',
 'plot',
 'pop',
 'pow',
 'prod',
 'product',
 'ptp',
 'put',
 'quantile',
 'radd',
 'rank',
 'ravel',
 'rdiv',
 'real',
 'reindex',
 'reindex_axis',
 'reindex_like',
 'rename',
 'rename_axis',
 'reorder_levels',
 'repeat',
 'replace',
 'resample',
 'reset_index',
 'reshape',
 'rfloordiv',
 'rmod',
 'rmul',
 'round',
 'rpow',
 'rsub',
 'rtruediv',
 'save',
 'searchsorted',
 'select',
 'sem',
 'set_axis',
 'set_value',
 'shape',
 'shift',
 'size',
 'skew',
 'slice_shift',
 'sort',
 'sort_index',
 'sortlevel',
 'squeeze',
 'std',
 'str',
 'strides',
 'sub',
 'subtract',
 'sum',
 'swapaxes',
 'swaplevel',
 'tail',
 'take',
 'to_clipboard',
 'to_csv',
 'to_dense',
 'to_dict',
 'to_frame',
 'to_hdf',
 'to_json',
 'to_msgpack',
 'to_period',
 'to_pickle',
 'to_sparse',
 'to_sql',
 'to_string',
 'to_timestamp',
 'tolist',
 'transpose',
 'truediv',
 'truncate',
 'tshift',
 'tz_convert',
 'tz_localize',
 'unique',
 'unstack',
 'update',
 'valid',
 'value_counts',
 'values',
 'var',
 'view',
 'where',
 'xs']

Методы объекта DataFrame

In [13]:
dir(pd000)
Out[13]:
['T',
 '_AXIS_ALIASES',
 '_AXIS_IALIASES',
 '_AXIS_LEN',
 '_AXIS_NAMES',
 '_AXIS_NUMBERS',
 '_AXIS_ORDERS',
 '_AXIS_REVERSED',
 '_AXIS_SLICEMAP',
 '__abs__',
 '__add__',
 '__and__',
 '__array__',
 '__array_wrap__',
 '__bool__',
 '__bytes__',
 '__class__',
 '__contains__',
 '__delattr__',
 '__delitem__',
 '__dict__',
 '__dir__',
 '__div__',
 '__doc__',
 '__eq__',
 '__finalize__',
 '__floordiv__',
 '__format__',
 '__ge__',
 '__getattr__',
 '__getattribute__',
 '__getitem__',
 '__getstate__',
 '__gt__',
 '__hash__',
 '__iadd__',
 '__idiv__',
 '__imul__',
 '__init__',
 '__invert__',
 '__ipow__',
 '__isub__',
 '__iter__',
 '__itruediv__',
 '__le__',
 '__len__',
 '__lt__',
 '__mod__',
 '__module__',
 '__mul__',
 '__ne__',
 '__neg__',
 '__new__',
 '__nonzero__',
 '__or__',
 '__pow__',
 '__radd__',
 '__rand__',
 '__rdiv__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__rfloordiv__',
 '__rmod__',
 '__rmul__',
 '__ror__',
 '__rpow__',
 '__rsub__',
 '__rtruediv__',
 '__rxor__',
 '__setattr__',
 '__setitem__',
 '__setstate__',
 '__sizeof__',
 '__str__',
 '__sub__',
 '__subclasshook__',
 '__truediv__',
 '__unicode__',
 '__weakref__',
 '__xor__',
 '_add_numeric_operations',
 '_agg_by_level',
 '_align_frame',
 '_align_series',
 '_apply_broadcast',
 '_apply_empty_result',
 '_apply_raw',
 '_apply_standard',
 '_at',
 '_auto_consolidate',
 '_box_col_values',
 '_box_item_values',
 '_check_inplace_setting',
 '_check_is_chained_assignment_possible',
 '_check_setitem_copy',
 '_clear_item_cache',
 '_combine_const',
 '_combine_frame',
 '_combine_match_columns',
 '_combine_match_index',
 '_combine_series',
 '_combine_series_infer',
 '_compare_frame',
 '_compare_frame_evaluate',
 '_consolidate_inplace',
 '_construct_axes_dict',
 '_construct_axes_dict_for_slice',
 '_construct_axes_dict_from',
 '_construct_axes_from_arguments',
 '_constructor',
 '_constructor_sliced',
 '_count_level',
 '_create_indexer',
 '_ensure_valid_index',
 '_expand_axes',
 '_flex_compare_frame',
 '_from_arrays',
 '_from_axes',
 '_get_agg_axis',
 '_get_axis',
 '_get_axis_name',
 '_get_axis_number',
 '_get_axis_resolvers',
 '_get_block_manager_axis',
 '_get_bool_data',
 '_get_cacher',
 '_get_index_resolvers',
 '_get_item_cache',
 '_get_numeric_data',
 '_get_values',
 '_getitem_array',
 '_getitem_column',
 '_getitem_frame',
 '_getitem_multilevel',
 '_getitem_slice',
 '_iat',
 '_iget_item_cache',
 '_iloc',
 '_indexed_same',
 '_info_axis',
 '_info_axis_name',
 '_info_axis_number',
 '_info_repr',
 '_init_dict',
 '_init_mgr',
 '_init_ndarray',
 '_internal_names',
 '_internal_names_set',
 '_is_cached',
 '_is_datelike_mixed_type',
 '_is_mixed_type',
 '_is_numeric_mixed_type',
 '_is_view',
 '_ix',
 '_ixs',
 '_join_compat',
 '_loc',
 '_local_dir',
 '_maybe_cache_changed',
 '_maybe_update_cacher',
 '_metadata',
 '_needs_reindex_multi',
 '_protect_consolidate',
 '_reduce',
 '_reindex_axes',
 '_reindex_axis',
 '_reindex_columns',
 '_reindex_index',
 '_reindex_multi',
 '_reindex_with_indexers',
 '_repr_fits_horizontal_',
 '_repr_fits_vertical_',
 '_repr_html_',
 '_reset_cache',
 '_sanitize_column',
 '_series',
 '_set_as_cached',
 '_set_axis',
 '_set_is_copy',
 '_set_item',
 '_setitem_array',
 '_setitem_frame',
 '_setitem_slice',
 '_setup_axes',
 '_slice',
 '_stat_axis',
 '_stat_axis_name',
 '_stat_axis_number',
 '_typ',
 '_unpickle_frame_compat',
 '_unpickle_matrix_compat',
 '_update_inplace',
 '_validate_dtype',
 '_xs',
 'abs',
 'add',
 'add_prefix',
 'add_suffix',
 'align',
 'all',
 'any',
 'append',
 'apply',
 'applymap',
 'as_blocks',
 'as_matrix',
 'asfreq',
 'astype',
 'at',
 'at_time',
 'axes',
 'between_time',
 'bfill',
 'blocks',
 'bool',
 'boxplot',
 'clip',
 'clip_lower',
 'clip_upper',
 'columns',
 'combine',
 'combineAdd',
 'combineMult',
 'combine_first',
 'compound',
 'consolidate',
 'convert_objects',
 'copy',
 'corr',
 'corrwith',
 'count',
 'cov',
 'cummax',
 'cummin',
 'cumprod',
 'cumsum',
 'describe',
 'diff',
 'div',
 'divide',
 'dot',
 'drop',
 'drop_duplicates',
 'dropna',
 'dtypes',
 'duplicated',
 'empty',
 'eq',
 'equals',
 'eval',
 'ffill',
 'fillna',
 'filter',
 'first',
 'first_valid_index',
 'floordiv',
 'from_csv',
 'from_dict',
 'from_items',
 'from_records',
 'ftypes',
 'ge',
 'get',
 'get_dtype_counts',
 'get_ftype_counts',
 'get_value',
 'get_values',
 'groupby',
 'gt',
 'head',
 'hist',
 'iat',
 'icol',
 'idxmax',
 'idxmin',
 'iget_value',
 'iloc',
 'index',
 'info',
 'insert',
 'interpolate',
 'irow',
 'is_copy',
 'isin',
 'isnull',
 'iteritems',
 'iterkv',
 'iterrows',
 'itertuples',
 'ix',
 'join',
 'keys',
 'kurt',
 'kurtosis',
 'last',
 'last_valid_index',
 'le',
 'load',
 'loc',
 'lookup',
 'lt',
 'mad',
 'mask',
 'max',
 'mean',
 'median',
 'memory_usage',
 'merge',
 'min',
 'mod',
 'mode',
 'mul',
 'multiply',
 'ndim',
 'ne',
 'notnull',
 'pct_change',
 'pivot',
 'pivot_table',
 'plot',
 'pop',
 'pow',
 'prod',
 'product',
 'quantile',
 'query',
 'radd',
 'rank',
 'rdiv',
 'reindex',
 'reindex_axis',
 'reindex_like',
 'rename',
 'rename_axis',
 'reorder_levels',
 'replace',
 'resample',
 'reset_index',
 'rfloordiv',
 'rmod',
 'rmul',
 'rpow',
 'rsub',
 'rtruediv',
 'save',
 'select',
 'select_dtypes',
 'sem',
 'set_axis',
 'set_index',
 'set_value',
 'shape',
 'shift',
 'size',
 'skew',
 'slice_shift',
 'sort',
 'sort_index',
 'sortlevel',
 'squeeze',
 'stack',
 'std',
 'sub',
 'subtract',
 'sum',
 'swapaxes',
 'swaplevel',
 'tail',
 'take',
 'to_clipboard',
 'to_csv',
 'to_dense',
 'to_dict',
 'to_excel',
 'to_gbq',
 'to_hdf',
 'to_html',
 'to_json',
 'to_latex',
 'to_msgpack',
 'to_panel',
 'to_period',
 'to_pickle',
 'to_records',
 'to_sparse',
 'to_sql',
 'to_stata',
 'to_string',
 'to_timestamp',
 'to_wide',
 'transpose',
 'truediv',
 'truncate',
 'tshift',
 'tz_convert',
 'tz_localize',
 'unstack',
 'update',
 'values',
 'var',
 'where',
 'xs']
In [12]:
dict(pd000)
Out[12]:
{'2013': Lada          151527
 Renault*       67208
 KIA            60027
 Nissan*        44188
 Hyundai*       56582
 Toyota*        44610
 Chevrolet      52489
 VW             49477
 Mitsubishi     26322
 Name: 2013, dtype: int64, '2013.1': Lada          44100
 Renault*      19178
 KIA           18303
 Nissan*        8272
 Hyundai*      15868
 Toyota*       15278
 Chevrolet     16083
 VW            14203
 Mitsubishi     7182
 Name: 2013.1, dtype: int64, '2014': Lada          128633
 Renault*       63647
 KIA            60033
 Nissan*        57579
 Hyundai*       57240
 Toyota*        50160
 Chevrolet      48586
 VW             45828
 Mitsubishi     27943
 Name: 2014, dtype: int64, '2014.1': Lada          37030
 Renault*      17395
 KIA           17744
 Nissan*       11835
 Hyundai*      15933
 Toyota*       15103
 Chevrolet     13279
 VW            11497
 Mitsubishi     6101
 Name: 2014.1, dtype: int64, 'Unnamed: 6': Lada         NaN
 Renault*     NaN
 KIA          NaN
 Nissan*      NaN
 Hyundai*     NaN
 Toyota*      NaN
 Chevrolet    NaN
 VW           NaN
 Mitsubishi   NaN
 Name: Unnamed: 6, dtype: float64, 'YoY %': Lada          -15%
 Renault*       -5%
 KIA             0%
 Nissan*        30%
 Hyundai*        1%
 Toyota*        12%
 Chevrolet      -7%
 VW             -7%
 Mitsubishi      6%
 Name: YoY %, dtype: object, 'YoY %.1': Lada          -16%
 Renault*       -9%
 KIA            -3%
 Nissan*        43%
 Hyundai*        0%
 Toyota*        -1%
 Chevrolet     -17%
 VW            -19%
 Mitsubishi    -15%
 Name: YoY %.1, dtype: object}
In [ ]:
 


Посты чуть ниже также могут вас заинтересовать

Комментариев нет:

Отправить комментарий