import pandas as pd
import numpy as np

my_dictionary = {'a' : 45., 'b' : -19.5, 'c' : 4444}
my_series = pd.Series(my_dictionary)
my_series

"""
Explanation: Vectorized Operations

not necessary to write loops for element-by-element operations
pandas' Series objects can be passed to MOST NumPy functions

documentation: http://pandas.pydata.org/pandas-docs/stable/basics.html
End of explanation
"""


my_series + my_series

"""
Explanation: add Series without loop
End of explanation
"""


3 * my_series + 5

"""
Explanation: Series within arithmetic expression
End of explanation
"""


np.exp(my_series)

"""
Explanation: Series used as argument to NumPy function
End of explanation
"""


my_series[1:]

my_series[:-1]

my_series[1:] + my_series[:-1]

"""
Explanation: A key difference between Series and ndarray is that operations between Series automatically align the data based on
label. Thus, you can write computations without giving consideration to whether the Series involved have the same labels.
End of explanation
"""


def multiply_by_ten (input_element):
    return input_element * 10.0

my_series.map(multiply_by_ten)

"""
Explanation: Apply Python functions on an element-by-element basis
End of explanation
"""


series_of_strings = pd.Series(['A', 'B', 'C', 'Aaba', 'Baca', np.nan, 'CABA', 'dog', 'cat'])
series_of_strings.str.lower()

"""
Explanation: Vectorized string methods
Series is equipped with a set of string processing methods that make it easy to operate on each element of the array. Perhaps most importantly, these methods exclude missing/NA values automatically.
End of explanation
"""


