In [1]:
%pylab
In [2]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
In [3]:
s = pd.Series([1,3,5,np.nan,6,8])
In [4]:
s
Out[4]:
In [5]:
dates = pd.date_range('20130101',periods=6)
In [6]:
dates
Out[6]:
In [6]:
In [7]:
df = pd.DataFrame(np.random.randn(6,4),index=dates,columns=list('ABCD'))
In [8]:
df
Out[8]:
In [8]:
In [9]:
df2 = pd.DataFrame({ 'A' : 1.,
....: 'B' : pd.Timestamp('20130102'),
....: 'C' : pd.Series(1,index=list(range(4)),dtype='float32'),
....: 'D' : np.array([3] * 4,dtype='int32'),
....: 'E' : 'foo' })
In [10]:
df2
Out[10]:
In [11]:
df2.dtypes
Out[11]:
In [11]:
In [12]:
df.head()
Out[12]:
In [13]:
df.tail(3)
Out[13]:
In [14]:
df.index
Out[14]:
In [15]:
df.columns
Out[15]:
In [16]:
df.values
Out[16]:
In [17]:
df.describe()
Out[17]:
In [18]:
df.T
Out[18]:
In [18]:
In [19]:
df.sort_index(axis=1, ascending=False)
Out[19]:
In [20]:
df.sort(columns='B')
Out[20]:
In [21]:
df['A']
Out[21]:
In [22]:
df[0:3]
Out[22]:
In [23]:
df['20130102':'20130104']
Out[23]:
In [24]:
df.loc[dates[0]]
Out[24]:
In [25]:
df.loc[:,['A','B']]
Out[25]:
In [26]:
df.loc['20130102':'20130104',['A','B']]
Out[26]:
In [27]:
df.loc['20130102',['A','B']]
Out[27]:
In [28]:
df.loc[dates[0],'A']
Out[28]:
In [29]:
df.at[dates[0],'A']
Out[29]:
In [30]:
df.iloc[3]
Out[30]:
In [31]:
df.iloc[3:5,0:2]
Out[31]:
In [32]:
df.iloc[[1,2,4],[0,2]]
Out[32]:
In [33]:
df.iloc[1:3,:]
Out[33]:
In [34]:
df.iloc[:,1:3]
Out[34]:
In [35]:
df.iloc[1,1]
Out[35]:
In [36]:
df.iat[1,1]
Out[36]:
In [ ]:
In [29]:
In [29]:
In [29]: