Posts

Showing posts from February, 2018

Working with Pandas

Working with Pandas In [1]: import numpy as np import pandas as pd s = pd . Series ([ 1 , 3 , 5 , np . nan , 6 , 8 ]) print ( s ) 0 1.0 1 3.0 2 5.0 3 NaN 4 6.0 5 8.0 dtype: float64 In [2]: dates = pd . date_range ( '20130101' , periods = 6 ) print ( dates ) DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06'], dtype='datetime64[ns]', freq='D') In [5]: df = pd . DataFrame ( np . random . randn ( 6 , 4 ), index = dates , columns = ( 'A' , 'B' , 'C' , 'D' )) #using series print ( df ) A B C D 2013-01-01 0.375465 1.208336 0.402344 0.620279 2013-01-02 -1.013392 0.697856 -...