import pandas as pd
from pandas import Series, DataFrame

"""
Explanation: Pandas Overview

Data analysis package for use with Python
Data structures are the fundamental elements
1D - Series
2D - DataFrame
Easy to work with labeled (or relational) data in SQL tables or Excel spreadsheets
Documentation: http://pandas.pydata.org/pandas-docs/version/0.19.1/

Import the Pandas Package
End of explanation
"""


series1 = Series([1,2,3,4,5])
series1.name = 'MyFirstSeries'
series1.index.name = 'Indx'
series1

series1.index

series1.values

"""
Explanation: Series
A series is a 1-Dimensional object similar to an array. There will be an array of data labels corresponding to an array of data.
Create series1 and display its indices and values:
End of explanation
"""


series2 = Series([10,20,30], index=['a','b','c'])
series2

"""
Explanation: Create series2 with custom indices:
End of explanation
"""


series2[0] == series2['a']     #check value of an index

series1[series1 > 3]           #get values greater than 3

series2 / 2                    #scalar division of a series

series2.isnull()               #check for nulls (multiple)
pd.isnull(series2)

List = ['c','a','b']           #get series values by passing in a List
series2[List]

series1 + series2

"""
Explanation: Series indexing and operations
End of explanation
"""


df = pd.read_csv("data1.csv", header=None)     #import csv file

df.columns = ["ID","Name", "Birthday"]

df.head()                                      #view top 5 lines

df.tail(1)                                     #view last line

"""
Explanation: Import DataStructure from File
End of explanation
"""


df['Name']                 #index based on column name (multiple)
df.Name

df.ix[0]                   #index based on row number

df[df['ID'] < 60]          #index based on values

"""
Explanation: Data Structure Indexing
End of explanation
"""


df['ID+1'] = df.apply(lambda row: row['ID'] + 1, axis=1)
df

"""
Explanation: Create new column w/lambda function which adds 1 to each row in 'ID'
End of explanation
"""


