Панда обозначават колона име

Примерен код

5
0

създаване на рамка на данни с имена на колони pandas

In [4]: import pandas as pd
In [5]: df = pd.DataFrame(columns=['A','B','C','D','E','F','G'])
In [6]: df
Out[6]:
Empty DataFrame
Columns: [A, B, C, D, E, F, G]
Index: []
1
0

как да се даде име на колона в панди

>gapminder.rename(columns={'pop':'population',
                          'lifeExp':'life_exp',
                          'gdpPercap':'gdp_per_cap'}, 
                 inplace=True)
 
>print(gapminder.columns)
 
Index([u'country', u'year', u'population', u'continent', u'life_exp',
       u'gdp_per_cap'],
      dtype='object')
 
>gapminder.head(3)
 
       country  year  population continent  life_exp  gdp_per_cap
0  Afghanistan  1952     8425333      Asia    28.801   779.445314
1  Afghanistan  1957     9240934      Asia    30.332   820.853030
2  Afghanistan  1962    10267083      Asia    31.997   853.100710

Подобни страници

Подобни страници с примери

На други езици

Тази страница на други езици

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Íslensk
..................................................................................................................

Популярно в тази категория

Популярните страници с примери в категория