In [1]:
import pandas as pd
%matplotlib inline

In [2]:
dateparse = lambda x: pd.datetime.strptime(x, '%Y%m%d')

In [3]:
soi = pd.read_csv('http://www.bom.gov.au/climate/enso/soi.txt', parse_dates=True, 
                 date_parser=dateparse, header=None, usecols=[1,2], index_col=0, names=['Date','soi'])
soi = soi.resample('D').bfill()
soi.plot()


Out[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x6a6e8370>

In [4]:
nino4 = pd.read_csv('http://www.bom.gov.au/climate/enso/nino_4.txt', parse_dates=True, 
                 date_parser=dateparse, header=None, usecols=[1,2], index_col=0, names=['Date','nino4'])
nino4 = nino4.resample('D').bfill()
nino4.plot()


Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x69499c50>

In [5]:
nino3 = pd.read_csv('http://www.bom.gov.au/climate/enso/nino_3.txt', parse_dates=True, 
                 date_parser=dateparse, header=None, usecols=[1,2], index_col=0, names=['Date','nino3'])
nino3 = nino3.resample('D').bfill()
nino3.plot()


Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x69431b10>

In [6]:
nino2 = pd.read_csv('http://www.bom.gov.au/climate/enso/nino_2.txt', parse_dates=True, 
                 date_parser=dateparse, header=None, usecols=[1,2], index_col=0, names=['Date','nino2'])
nino2 = nino2.resample('D').bfill()
nino2.plot()


Out[6]:
<matplotlib.axes._subplots.AxesSubplot at 0x693bbb70>

In [7]:
nino1 = pd.read_csv('http://www.bom.gov.au/climate/enso/nino_1.txt', parse_dates=True, 
                 date_parser=dateparse, header=None, usecols=[1,2], index_col=0, names=['Date','nino1'])
nino1 = nino1.resample('D').bfill()
nino1.plot()


Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x692eeb90>

In [8]:
nino34 = pd.read_csv('http://www.bom.gov.au/climate/enso/nino_3.4.txt', parse_dates=True, 
                 date_parser=dateparse, header=None, usecols=[1,2], index_col=0, names=['Date','nino34'])
nino34 = nino34.resample('D').bfill()
nino34.plot()


Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x69279bb0>

In [9]:
# Crea df desde noaa
oni = pd.read_fwf('http://www.cpc.ncep.noaa.gov/data/indices/oni.ascii.txt', widths=(6, 6, 6, 6))

# Diccionario temporada mes intermedio
#d = dict(oni.SEAS[:12])
#dd = {}
#for x in d.keys():
#    dd[d[x]] = x+1

dd = {'AMJ': 5, 'ASO': 9, 'DJF': 1, 'FMA': 3, 'JAS': 8, 'JFM': 2, 'JJA': 7, 'MAM': 4,
      'MJJ': 6, 'NDJ': 12, 'OND': 11, 'SON': 10}

# Reemplaza temporada por numero mes
oni.SEAS.replace(dd, inplace=True)

# Crea columna con inicio mes
oni['Date'] = oni.apply(lambda row: "%.f-%.f-1"%(row['YR'],row['SEAS']), axis=1)

# oni drop SEAS y YR
oni.drop(['SEAS', 'YR'], axis=1, inplace=True)

# Indice Date
oni['Date']  = pd.to_datetime(oni['Date'])
oni.set_index('Date', inplace=True)

In [10]:
oni.plot(figsize=(10, 10), subplots=True, sharex=True)


Out[10]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x6920c730>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x69179db0>], dtype=object)

In [11]:
# Crea df desde noaa
url = 'http://www.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/detrend.nino34.ascii.txt'
nino34 = pd.read_csv(url, sep='\s+')

# Crea columna con inicio mes
nino34['Date'] = nino34.apply(lambda row: "%.f-%.f-1"%(row['YR'],row['MON']), axis=1)

# nino34 drop SEAS y YR
nino34.drop(['MON', 'YR'], axis=1, inplace=True)

# Indice Date
nino34['Date']  = pd.to_datetime(nino34['Date'])
nino34.set_index('Date', inplace=True)

In [12]:
nino34.plot(figsize=(10, 10), subplots=True, sharex=True)


Out[12]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x69259f10>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x68df7fd0>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x68f2b650>], dtype=object)

In [ ]: