import pandas as pd
import numpy as np

"""
Explanation: Creating Data Frames
documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html
DataFrame is a 2-dimensional labeled data structure with columns of potentially different types. You can think of it
like a spreadsheet or SQL table, or a dict of Series objects.
You can create a data frame using:
- Dict of 1D ndarrays, lists, dicts, or Series
- 2-D numpy.ndarray
- Structured or record ndarray
- A Series
- Another DataFrame
Data Frame attributes
| T       | Transpose index and columns                                                                                       |   |
|---------|-------------------------------------------------------------------------------------------------------------------|---|
| at      | Fast label-based scalar accessor                                                                                  |   |
| axes    | Return a list with the row axis labels and column axis labels as the only members.                                |   |
| blocks  | Internal property, property synonym for as_blocks()                                                               |   |
| dtypes  | Return the dtypes in this object.                                                                                 |   |
| empty   | True if NDFrame is entirely empty [no items], meaning any of the axes are of length 0.                            |   |
| ftypes  | Return the ftypes (indication of sparse/dense and dtype) in this object.                                          |   |
| iat     | Fast integer location scalar accessor.                                                                            |   |
| iloc    | Purely integer-location based indexing for selection by position.                                                 |   |
| is_copy |                                                                                                                   |   |
| ix      | A primarily label-location based indexer, with integer position fallback.                                         |   |
| loc     | Purely label-location based indexer for selection by label.                                                       |   |
| ndim    | Number of axes / array dimensions                                                                                 |   |
| shape   | Return a tuple representing the dimensionality of the DataFrame.                                                  |   |
| size    | number of elements in the NDFrame                                                                                 |   |
| style   | Property returning a Styler object containing methods for building a styled HTML representation fo the DataFrame. |   |
| values  | Numpy representation of NDFrame                                                                                   |   |
End of explanation
"""


my_dictionary = {'a' : 45., 'b' : -19.5, 'c' : 4444}
print(my_dictionary.keys())
print(my_dictionary.values())


"""
Explanation: Creating data frames from various data types
documentation: http://pandas.pydata.org/pandas-docs/stable/dsintro.html
cookbook: http://pandas.pydata.org/pandas-docs/stable/cookbook.html
create data frame from Python dictionary
End of explanation
"""


cookbook_df = pd.DataFrame({'AAA' : [4,5,6,7], 'BBB' : [10,20,30,40],'CCC' : [100,50,-30,-50]})
cookbook_df

"""
Explanation: constructor without explicit index
End of explanation
"""


series_dict = {'one' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
               'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
series_df = pd.DataFrame(series_dict)
series_df

"""
Explanation: constructor contains dictionary with Series as values
End of explanation
"""


produce_dict = {'veggies': ['potatoes', 'onions', 'peppers', 'carrots'],
                'fruits': ['apples', 'bananas', 'pineapple', 'berries']}
produce_dict

"""
Explanation: dictionary of lists
End of explanation
"""


data2 = [{'a': 1, 'b': 2}, {'a': 5, 'b': 10, 'c': 20}]
pd.DataFrame(data2)

"""
Explanation: list of dictionaries
End of explanation
"""


pd.DataFrame({('a', 'b'): {('A', 'B'): 1, ('A', 'C'): 2},
('a', 'a'): {('A', 'C'): 3, ('A', 'B'): 4},
('a', 'c'): {('A', 'B'): 5, ('A', 'C'): 6},
('b', 'a'): {('A', 'C'): 7, ('A', 'B'): 8},
('b', 'b'): {('A', 'D'): 9, ('A', 'B'): 10}})

"""
Explanation: dictionary of tuples, with  multi index
End of explanation
"""


