In [1]:
import pandas as pd
from collections import OrderedDict
scientists = pd.read_csv('./data/scientists.csv')
In [2]:
ages = scientists['Age']
print('max: {}'.format(ages.max()))
print("mean: {}".format(ages.mean()))
In [3]:
ages[ages > ages.mean()]
Out[3]:
broadcasting¶
In [4]:
print(pd.Series([1, 100]))
print("\n=================================\n")
print(ages + pd.Series([1, 100]))
In [5]:
rev_age = ages.sort_index(ascending=False)
print(rev_age) # index의 역순
In [6]:
print(ages*2)
print("\n=================================\n")
print(ages + ages.sort_index(ascending=False))
ages * 2
와 ages+ages.sort_index(ascending=False)
의 결과값이 동일
벡터와 벡터의 연산은 일치하는 인덱스끼리 값을 수행
In [7]:
from IPython.core.display import HTML, display
display(HTML("<style> .container{width:100% !important;}</style>"))
'pandas > basic' 카테고리의 다른 글
07.handling_dataframe(bool-apply) (0) | 2018.12.09 |
---|---|
06.handling_dataframe(bool) (0) | 2018.12.09 |
04.handling_series(basic) (0) | 2018.12.09 |
03.create_data_frame (0) | 2018.12.09 |
02.basic_statistic (0) | 2018.12.09 |