Created
August 31, 2017 12:31
-
-
Save Zerk123/7907af2e618c00906eee3d40b580568e to your computer and use it in GitHub Desktop.
Python Data Structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import datetime | |
| import pandas_datareader.data as web | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from numpy import nan as NA | |
| #PANDAS | |
| #PANDAS Data Structures | |
| #Series | |
| obj = pd.Series([2,4,6,7,8]) | |
| obj = pd.Series([2,4,6,7,8], index = ['a','b','c','d','e']) | |
| print(obj) | |
| print(obj.values) | |
| print(obj.index) | |
| print(obj['a']) | |
| print(obj[['a','b','c']]) | |
| print(obj[obj>2]) | |
| print(obj*2) | |
| #Dictionary | |
| Dict={'PWR': +91,'LHR': +42, 'KHT':+92} | |
| print(Dict) | |
| obj=pd.Series(Dict) | |
| print(obj) | |
| #Lists | |
| states = ['KPK','PUNJAB','SINDH','BALUCHISTAN','GILGAT'] | |
| print(states) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment