Difference between revisions of "Python: Pandas - The Series Data Structure"
From MyWiki
Line 51: | Line 51: | ||
s | s | ||
+ | </source> | ||
+ | Querying a series | ||
+ | <source lang="python"> | ||
− | + | sports = {'Archery': 'Bhutan', | |
− | + | 'Golf': 'Scotland', | |
+ | 'Sumo': 'Japan', | ||
+ | 'Taekwondo': 'South Korea'} | ||
+ | s = pd.Series(sports) | ||
+ | s | ||
</source> | </source> |
Revision as of 15:27, 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
Querying a series
sports = {'Archery': 'Bhutan', 'Golf': 'Scotland', 'Sumo': 'Japan', 'Taekwondo': 'South Korea'} s = pd.Series(sports) s