In [2]:
import numpy as np
import pandas as pd
from pandas import DataFrame, Series
In [3]:
years = [1990, 1991, 1992, 2008, 2012, 2015, 1987, 1969, 2013, 2008, 1999 ]
In [4]:
decade_bins = [1960, 1970, 1980, 1990, 2000, 2010, 2020]
In [5]:
decade_cat = pd.cut(years, decade_bins)
In [7]:
decade_cat
Out[7]:
In [8]:
decade_cat.categories
Out[8]:
In [9]:
pd.value_counts(decade_cat)
Out[9]:
In [10]:
pd.cut(years, 2, precision=1)
Out[10]:
In [ ]: