In [1]:
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
In [2]:
arr = np.array([[1,2,np.nan], [np.nan,3,4]])
In [3]:
dframe1 = DataFrame(arr, index=['A', 'B'], columns=['One', 'Two', 'Three'])
dframe1
Out[3]:
In [4]:
dframe1.sum()
Out[4]:
In [5]:
dframe1.sum(axis=1)
Out[5]:
In [6]:
dframe1.idxmin()
Out[6]:
In [7]:
dframe1.cumsum()
Out[7]:
In [8]:
dframe1.describe()
Out[8]:
In [9]:
from IPython.display import YouTubeVideo
In [10]:
YouTubeVideo('xGbpuFNR1ME')
Out[10]:
In [13]:
YouTubeVideo('4EXNedimDMs')
Out[13]:
In [15]:
import pandas.io.data as pdweb
import datetime
In [16]:
prices = pdweb.get_data_yahoo(['CVX', 'XOM', 'BP'], start=datetime.datetime(2010, 1,1), end = datetime.datetime(2013, 1,1))['Adj Close']
prices.head()
Out[16]:
In [17]:
volume = pdweb.get_data_yahoo(['CVX', 'XOM', 'BP'], start=datetime.datetime(2010, 1,1), end = datetime.datetime(2013, 1,1))['Volume']
In [18]:
volume.head()
Out[18]:
In [19]:
rets = prices.pct_change()
In [20]:
corr = rets.corr
In [22]:
%matplotlib inline
prices.plot()
Out[22]:
In [27]:
import seaborn as sns
import matplotlib.pyplot as plt
In [33]:
sns.heatmap(corr(), annot=True)
Out[33]:
In [38]:
ser1 = Series(['w', 'w', 'x', 'y', 'z', 'w', 'x', 'y', 'x', 'a'])
ser1
Out[38]:
In [40]:
ser1.unique()
Out[40]:
In [41]:
ser1.value_counts()
Out[41]:
In [ ]: