In [2]:
import numpy as np

import pandas as pd

from pandas import Series, DataFrame

In [3]:
obj = Series([3,6,9,12])

In [4]:
obj


Out[4]:
0     3
1     6
2     9
3    12
dtype: int64

In [5]:
obj.values


Out[5]:
array([ 3,  6,  9, 12])

In [6]:
obj.index


Out[6]:
RangeIndex(start=0, stop=4, step=1)

In [12]:
ww2_cas = Series([8700000, 4300000, 3000000, 2100000, 400000], index=['USSR', 'Germany', 'China', 'Japan', 'USA'])

In [13]:
ww2_cas


Out[13]:
USSR       8700000
Germany    4300000
China      3000000
Japan      2100000
USA         400000
dtype: int64

In [14]:
ww2_cas['USA']


Out[14]:
400000

In [15]:
ww2_cas[ww2_cas > 4000000]


Out[15]:
USSR       8700000
Germany    4300000
dtype: int64

In [16]:
'USSR' in ww2_cas


Out[16]:
True

In [17]:
ww2_dict = ww2_cas.to_dict()

ww2_dict


Out[17]:
{'China': 3000000,
 'Germany': 4300000,
 'Japan': 2100000,
 'USA': 400000,
 'USSR': 8700000}

In [18]:
ww2_series = Series(ww2_dict)

In [19]:
ww2_series


Out[19]:
China      3000000
Germany    4300000
Japan      2100000
USA         400000
USSR       8700000
dtype: int64

In [20]:
countries = ['China', 'Germany', 'Japan', 'USA', 'USSR', 'Argentina']

In [22]:
obj2 = Series(ww2_dict, index = countries) 

obj2


Out[22]:
China        3000000.0
Germany      4300000.0
Japan        2100000.0
USA           400000.0
USSR         8700000.0
Argentina          NaN
dtype: float64

In [23]:
pd.isnull(obj2)


Out[23]:
China        False
Germany      False
Japan        False
USA          False
USSR         False
Argentina     True
dtype: bool

In [24]:
pd.notnull(obj2)


Out[24]:
China         True
Germany       True
Japan         True
USA           True
USSR          True
Argentina    False
dtype: bool

In [25]:
ww2_series


Out[25]:
China      3000000
Germany    4300000
Japan      2100000
USA         400000
USSR       8700000
dtype: int64

In [26]:
ww2_series + obj2


Out[26]:
Argentina           NaN
China         6000000.0
Germany       8600000.0
Japan         4200000.0
USA            800000.0
USSR         17400000.0
dtype: float64

In [27]:
obj2.name = 'World War 2 Casualties'

In [28]:
obj2


Out[28]:
China        3000000.0
Germany      4300000.0
Japan        2100000.0
USA           400000.0
USSR         8700000.0
Argentina          NaN
Name: World War 2 Casualties, dtype: float64

In [29]:
obj2.index.name = 'Countries'

In [30]:
obj2


Out[30]:
Countries
China        3000000.0
Germany      4300000.0
Japan        2100000.0
USA           400000.0
USSR         8700000.0
Argentina          NaN
Name: World War 2 Casualties, dtype: float64

In [ ]: