Difference between revisions of "Python: Pandas - The Series Data Structure"
From MyWiki
Line 21: | Line 21: | ||
import numpy as np | import numpy as np | ||
np.nan == None | np.nan == None | ||
+ | |||
+ | |||
+ | np.nan == np.nan | ||
+ | |||
+ | |||
+ | np.isnan(np.nan) | ||
+ | |||
+ | |||
+ | |||
+ | sports = {'Archery': 'Bhutan', | ||
+ | 'Golf': 'Scotland', | ||
+ | 'Sumo': 'Japan', | ||
+ | 'Taekwondo': 'South Korea'} | ||
+ | s = pd.Series(sports) | ||
+ | s | ||
+ | |||
+ | s.index | ||
+ | |||
+ | |||
+ | s = pd.Series(['Tiger', 'Bear', 'Moose'], index=['India', 'America', 'Canada']) | ||
+ | s | ||
+ | |||
+ | |||
+ | sports = {'Archery': 'Bhutan', | ||
+ | 'Golf': 'Scotland', | ||
+ | 'Sumo': 'Japan', | ||
+ | 'Taekwondo': 'South Korea'} | ||
+ | s = pd.Series(sports, index=['Golf', 'Sumo', 'Hockey']) | ||
+ | s | ||
+ | |||
+ | |||
+ | |||
+ | |||
</source> | </source> |
Revision as of 15:26, 28 July 2019
import pandas as pd pd.Series? animals = ['Tiger', 'Bear', 'Moose'] pd.Series(animals) numbers = [1, 2, 3] pd.Series(numbers) animals = ['Tiger', 'Bear', None] pd.Series(animals) numbers = [1, 2, None] pd.Series(numbers) import numpy as np np.nan == None np.nan == np.nan np.isnan(np.nan) sports = {'Archery': 'Bhutan', 'Golf': 'Scotland', 'Sumo': 'Japan', 'Taekwondo': 'South Korea'} s = pd.Series(sports) s s.index s = pd.Series(['Tiger', 'Bear', 'Moose'], index=['India', 'America', 'Canada']) s sports = {'Archery': 'Bhutan', 'Golf': 'Scotland', 'Sumo': 'Japan', 'Taekwondo': 'South Korea'} s = pd.Series(sports, index=['Golf', 'Sumo', 'Hockey']) s