Skip to content

Instantly share code, notes, and snippets.

@Zerk123
Created August 31, 2017 12:31
Show Gist options
  • Select an option

  • Save Zerk123/7907af2e618c00906eee3d40b580568e to your computer and use it in GitHub Desktop.

Select an option

Save Zerk123/7907af2e618c00906eee3d40b580568e to your computer and use it in GitHub Desktop.
Python Data Structures
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