import pandas as pd s = pd.Series([1, 3, 5, 7, 9]) print(s)
import pandas as pd s = pd.Series([1, 3, 5, 7, 9]) print(s[0]) # prints the first element (1) print(s[2:]) # prints elements 2 to the end (5, 7, 9)
import pandas as pd s = pd.Series([1, 3, 5, 7, 9], index=['a', 'b', 'c', 'd', 'e']) print(s['c']) # prints the element with index 'c' (5)
import pandas as pd s = pd.Series([1, 3, 5, 7, 9]) print(s[s > 5]) # prints elements that are greater than 5 (7, 9)We can filter a Series by a condition by using the condition inside square brackets. Overall, these examples demonstrate the various ways to create, manipulate and access elements within a Series using the pandas package library.