import sys
print(sys.version)
import numpy as np
print(np.__version__)
import pandas as pd
print(pd.__version__)

"""
Explanation: General pandas Concepts
End of explanation
"""


pd.Index

"""
Explanation: Now we’ve covered numpy the basis for pandas. We’ve covered some of the more advanced python concepts like list comprehensions and lambda functions. Let’s jump back to our roadmap.
We’ve covered the general ecosystem. We’ve covered a lot of numpy, now let’s get our hands dirty with some real data and actually using pandas. I hope you’ve watched the numpy videos that we covered earlier, they may seem academic but they’re really going to provide a fantastic foundation for what we’re going to learn now.
Now I'm going to breeze through a couple of subjects right now. Don’t feel the need to take notes or even try this code yourself. You can if you like, but it’s mainly to introduce you to the power of pandas, not for you to copy.
Pandas is made up of a couple of core types.
We’ve got an index. The index is a way of querying the data in an array or Series or querying the data in a Series or DataFrame.
End of explanation
"""


pd.Series

series_ex = pd.Series(np.arange(26))
series_ex

"""
Explanation: We’ve got the Series. The Series is like a 1 dimensional array in numpy. It has some helper functions and an index that allows for querying of the data in simple ways.
We can make a simple Series from a numpy array.
End of explanation
"""


series_ex.index

"""
Explanation: Now that we’ve created it. We can see it has an index, that we just talked about, as well as values. When we print these out, they should look similar - just like numpy arrays. Now here is where the series gets powerful.
End of explanation
"""


import string
lcase = string.ascii_lowercase
ucase = string.ascii_uppercase
print(lcase, ucase)

lcase = list(lcase)
ucase = list(ucase)
print(lcase)
print(ucase)

series_ex.index = lcase

series_ex.index

series_ex

"""
Explanation: we can replace the index with our own index. In this example I’ll use the lower case values of ascii characters.
End of explanation
"""


series_ex.ix['d':'k']

series_ex.ix['f']

"""
Explanation: Now we can query just like we would if an array. You can think of the Series like an extremely powerful array.
We can query either sections or specific values.
End of explanation
"""


pd.DataFrame

"""
Explanation: Now don’t worry about the functions that I’m using. We’re going to go over those in detail - I just wanted to introduce the concept.
We’ve got the DataFrame which is like a matrix or series of series’. It also has an index (or multiple indexes).
End of explanation
"""


letters = pd.DataFrame([lcase, ucase, list(range(26))])
letters

"""
Explanation: Let’s go ahead and create one. We’ve make it from the lowercase, uppercase, and a number range.
End of explanation
"""


letters = letters.transpose()
letters.head()

letters.columns

letters.index

"""
Explanation: Just like a numpy array we can transpose it.
End of explanation
"""


letters.columns = ['lowercase','uppercase','number']

letters.lowercase

letters['lowercase']

"""
Explanation: But now that we have columns as well as an index, we can rename the columns to better describe and query the data.
End of explanation
"""


letters.index = pd.date_range('9/1/2012',periods=26)

letters

letters['9-10-2012':'9-15-2012']

"""
Explanation: We can even set up a date range to associate each letter with a date. Now obviously this isn’t too helpful for the alphabet, but this allows you to do some amazing things once you are analyzing real data.
End of explanation
"""


