import pandas as pd
from pandas import Series, DataFrame

series_1 = Series([-2, -1, 0, 1, 2, 3, 4, 5])
series_1

series_1.values

series_1.index

series_2 = Series([1, 2, 3], index=['a', 'b', 'c'])
series_2

series_2.index

series_2['a']

series_2[['a', 'b']]

series_2[series_2 > 1]

series_2 * 2

"""
Explanation: Pandas Data Structures
Series
From the Book Python for Data Analysis: A Series is a one-dimensional array-like object containing an array of data and an associated array of data labels, called its index.
End of explanation
"""


numbers_1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
series_3 = Series(numbers_1)
series_3

numbers_2_index = ['a', 'b', 'c', 'd']
numbers_2 = {'a': 1, 'b': 2, 'c': 3}
series_4 = Series(numbers_2, index=numbers_2_index)
series_4

pd.isnull(series_4) # same as series_4.isnull()

pd.notnull(series_4)

series_3 + series_4

series_4.name = 'numbers'
series_4.index.name = 'letter'
series_4

series_4.index = ['1', '2', '3', 'x'] # update index
series_4

"""
Explanation: Using a dict for Series
End of explanation
"""


data_1 = {
    'pet': ['Toffee', 'Candy', 'Cake', 'Sussy'],
    'age': [3, 1, 2, 4],
}
frame_1 = DataFrame(data_1)
frame_1

frame_1['age'] # dict-like notation

frame_1.pet # attribute

frame_2 = DataFrame(data_1, columns=['pet', 'age', 'toy'], index=['one', 'two', 'three', 'four'])
frame_2

frame_2.ix['four'] # row

frame_2.toy = 'bone'
frame_2

frame_2.toy = Series(['bone', None, 'bone', 'bone'], index=['one', 'two', 'three', 'four'])
frame_2

frame_2['likes_bone_toy'] = frame_2.toy == 'bone'
frame_2

frame_2.T # transpose

frame_2.columns.name = 'Number'
frame_2.index.name = 'Pet'
frame_2

frame_2.values

frame_2.index

'one' in frame_2.index

frame_2.reindex(['four', 'three', 'two', 'one'], fill_value=0)

"""
Explanation: DataFrame
From the Book Python for Data Analysis: A DataFrame represents a tabular, spreadsheet-like data structure containing an ordered collection of columns, each of which can be a different value type. Can be thought as a dict of Series.
End of explanation
"""


fill_numbers = Series(['blue', 'yellow', 'green'], index=[0, 4, 8])
fill_numbers.reindex(range(12), method='ffill')

"""
Explanation: Interpolation / filling of values when reindex (Series)
End of explanation
"""


