import pandas as pd
from IPython.display import display
ds = pd.Series([1,2,3,4])
ds
ds = pd.Series([1,2,3,4], index=['a', 'b', 'c', 'd'])
ds
somedict = {
"d":4,
"a":1,
"c":3,
"b":2,
"e":5
}
ds = pd.Series(somedict)
# note, that resulting Series is ordered by dictionary's sorted keys:
ds
ds.index
# numerical or keyword indexes:
print(ds["a"])
print(ds[0])
# list indexes:
ds[['a', 'c', 'e']]
# slicing
ds["a":"d"]
ds
ds.index = ["A","B","C","D","E"]
ds
ds = pd.Series([1,2,3,4,5],index=["a","b","c","d","e"])
ds
# filtering by value
ds[ds>2]
ds*2
"a" in ds
"f" in ds
ds1 = pd.Series([1,3], index=["a","c"])
ds2 = pd.Series([2,3], index=["b","c"])
print(ds1+ds2)
ds = pd.Series([1,2,3])
ds