In [140]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import datetime as dt
import calendar

In [67]:
test_date = dt.datetime(2017,8,25)

In [237]:
df = pd.read_csv("transactions.csv")
df['Date'] = pd.to_datetime(df['Date'])
df = df.set_index(df['Date']).drop('Date',axis=1)

In [254]:
x = pd.to_datetime('2017-08-25')

In [239]:
def process_raw(tab):
    df = tab
    df['Date'] = pd.to_datetime(df['Date'])
    df = df.set_index(df['Date']).drop('Date',axis=1)
    return df

In [240]:
process_raw(pd.read_csv("transactions.csv"))


Out[240]:
Description Original Description Amount Transaction Type Category Account Name Labels Notes
Date
2017-09-09 Gig Car Share GIG CAR SHARE 0.50 debit Rental Car & Taxi Discover NaN NaN
2017-09-09 Gig Car Share GIG CAR SHARE 0.50 debit Rental Car & Taxi Discover NaN NaN
2017-09-10 Lyft LYFT *RIDE SUN 2PM 855-280-0278 CA 15.38 debit Rental Car & Taxi Discover NaN NaN
2017-09-10 Lyft LYFT *RIDE SUN 4PM 855-280-0278 CA 10.88 debit Rental Car & Taxi Discover NaN NaN
2017-09-09 Cafe Durant CAFE DURANT BERKELEY CA 9.66 debit Restaurants Discover NaN NaN
2017-09-08 Diyar Mediterranean Cusi DIYAR MEDITERRANEAN CUSI BERKELEY CA 8.73 debit Restaurants Discover NaN NaN
2017-08-31 Raleighs Pub RALEIGHS PUB BERKELEY CA 10.87 debit Alcohol & Bars Discover NaN NaN
2017-08-31 Internet Thank You INTERNET PAYMENT - THANK YOU 225.61 credit Credit Card Payment Discover NaN NaN
2017-08-29 Internet Thank You INTERNET PAYMENT - THANK YOU 155.53 credit Credit Card Payment Discover NaN NaN
2017-08-29 Ucb Recreational Sports UCB RECREATIONAL SPORTS 510-642-7796 CA 25.00 debit Gym Discover NaN NaN
2017-08-27 Berkeley Bowl Markesbe BERKELEY BOWL MARKESBE BERKELEY CA 200.61 debit Groceries Discover NaN NaN
2017-08-26 Chengdu Style Restaurant CHENGDU STYLE RESTAURANT BERKELEY CA 63.00 debit Restaurants Discover NaN NaN
2017-08-25 V A Cafe SQ *V&A CAFE BERKELEY CA0002305843011213890465 3.00 debit Restaurants Discover NaN NaN
2017-08-25 Lyft LYFT *RIDE FRI 12PM 855-280-0278 CA 11.69 debit Rental Car & Taxi Discover NaN NaN
2017-08-25 Lyft LYFT *RIDE FRI 12PM 855-280-0278 CA 35.11 debit Rental Car & Taxi Discover NaN NaN
2017-08-25 L Epi D SQ *L'EPI D'OR BAKERY CUPERTINO CA000115292150... 4.99 debit Restaurants Discover NaN NaN
2017-08-25 Lyft LYFT *RIDE FRI 10AM 855-280-0278 CA 30.85 debit Rental Car & Taxi Discover NaN NaN
2017-08-24 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 383.82 credit Credit Card Payment Discover NaN NaN
2017-08-23 Laval's Pizza LAVAL'S PIZZA BERKELEY CA 6.89 debit Fast Food Discover NaN NaN
2017-08-21 Chick-Fil-A CHICK-FIL-A #02765 WALNUT CREEK CA 8.39 debit Fast Food Discover NaN NaN
2017-08-21 Tea 1 SQ *TEA 1 BERKELEY BERKELEY CA0002305843011209... 4.25 debit Fast Food Discover NaN NaN
2017-08-21 Amazon AMAZON.COM AMZN.COM/BILLWA6M1Q94EWTEI 15.32 debit Shopping Discover NaN NaN
2017-08-20 Amazon AMAZON.COM AMZN.COM/BILLWA49VLZN1FMGG 15.42 debit Shopping Discover NaN NaN
2017-08-20 Lyft LYFT *RIDE SUN 7PM 855-280-0278 CA 6.50 debit Rental Car & Taxi Discover NaN NaN
2017-08-19 Comcast COMCAST CALIFORN CS 1X 800-266-2278 CA73603189... 39.99 debit Television Discover NaN NaN
2017-08-18 Lyft LYFT *RIDE FRI 8PM 855-280-0278 CA 7.09 debit Rental Car & Taxi Discover NaN NaN
2017-08-17 Laval's Pizza LAVAL'S PIZZA BERKELEY CA 8.75 debit Fast Food Discover NaN NaN
2017-08-13 Diyar Mediterranean Cusi DIYAR MEDITERRANEAN CUSI BERKELEY CA 18.55 debit Restaurants Discover NaN NaN
2017-08-12 Lyft LYFT *RIDE SAT 3PM 855-280-0278 CA 6.50 debit Rental Car & Taxi Discover NaN NaN
2017-08-12 Safeway SAFEWAY STORE 0691 BERKELEY CA 93.20 debit Groceries Discover NaN NaN
... ... ... ... ... ... ... ... ...
2016-11-10 Ucafe Berkeley SQ *UCAFE, BERKELEY BERKELEY CA000115292150743... 2.75 debit Restaurants Discover NaN NaN
2016-11-10 La Val's Pizza LAVAL'S PIZZA BERKELEY CA 9.30 debit Fast Food Discover NaN NaN
2016-11-09 Dumpling Express DUMPLING EXPRESS BERKELEY CA 8.54 debit Food & Dining Discover NaN NaN
2016-11-06 Ation 723 Tea Street 723 TEA STATION BERKELEY CA 8.27 debit Coffee Shops Discover NaN NaN
2016-11-04 Amazon AMAZON PICKUP POINTS 877-345-0975 WAVHOYB211YRP 25.61 debit Shopping Discover NaN NaN
2016-11-03 Artichokes SQ *ARTICHOKE BASILLE' BERKELEY CA000115292150... 5.20 debit Restaurants Discover NaN NaN
2016-11-02 Cafe Strada Berkeley CAFE STRADA, INC BERKELEY CA 2.95 debit Coffee Shops Discover NaN NaN
2016-11-02 Amazon AMAZON.COM AMZN.COM/BILLWAS92AN8Q6MPU 12.41 debit Shopping Discover NaN NaN
2016-10-30 Dumpling Express DUMPLING EXPRESS BERKELEY CA 8.54 debit Restaurants Discover NaN NaN
2016-10-30 Amazon AMAZON MKTPLACE PMTS AMZN.COM/BILLWAQXI26QETC0G 10.94 debit Shopping Discover NaN NaN
2016-10-30 Dumpling Express DUMPLING EXPRESS BERKELEY CA 8.54 debit Restaurants Discover NaN NaN
2016-10-29 Amazon AMAZON MKTPLACE PMTS AMZN.COM/BILLWAQXIRBS5R0F1 25.97 debit Shopping Discover NaN NaN
2016-10-26 Sharetea SQ *SHARETEA BERKELEY CA0001152921507419964410 4.10 debit Fast Food Discover NaN NaN
2016-10-24 Amazon AMAZON PICKUP POINTS 877-345-0975 WAEIYIHN10TWM 17.37 debit Shopping Discover NaN NaN
2016-10-23 Internet Thank You INTERNET PAYMENT - THANK YOU 136.10 credit Credit Card Payment Discover NaN NaN
2016-10-23 Ucb Housing Dining UCB HOUSING&DINING SVCS 510-643-6955 CA 20.00 debit Transfer for Cash Spending Discover NaN NaN
2016-10-16 Amazon AMAZON PICKUP POINTS 877-345-0975 WAG4Q9R3IKRN9 14.22 debit Shopping Discover NaN NaN
2016-10-15 Dumpling Express DUMPLING EXPRESS BERKELEY CA 8.04 debit Restaurants Discover NaN NaN
2016-10-15 Amazon AMAZON MKTPLACE PMTS AMZN.COM/BILLWAKYG48B5SZM0 16.95 debit Shopping Discover NaN NaN
2016-10-15 Amazon AMAZON PICKUP POINTS 877-345-0975 WAI8CZU4V6UT0 11.60 debit Shopping Discover NaN NaN
2016-10-14 Cafe Strada Berkeley CAFE STRADA, INC BERKELEY CA 1.95 debit Coffee Shops Discover NaN NaN
2016-10-07 Dumpling Express DUMPLING EXPRESS BERKELEY CA 8.54 debit Restaurants Discover NaN NaN
2016-10-01 Sweetheart Cafe SQ *SWEETHEART CAFE BERKELEY CA000115292150739... 3.11 debit Coffee Shops Discover NaN NaN
2016-09-30 Amazon AMAZON PICKUP POINTS 877-345-0975 WAQNFQ0I2N5VZ 12.46 debit Shopping Discover NaN NaN
2016-09-26 Amazon AMAZON MKTPLACE PMTS AMZN.COM/BILLWAPSZW18FL65W 12.95 debit Shopping Discover NaN NaN
2016-09-26 Simply Bowl SIMPLY BOWL BERKELEY CA 11.50 debit Restaurants Discover NaN NaN
2016-09-25 Amazon AMAZON MKTPLACE PMTS AMZN.COM/BILLWAILEP1GHK5UI 4.95 debit Shopping Discover NaN NaN
2016-09-25 Ucb Housing Dining UCB HOUSING&DINING SVCS 510-643-6955 CA 20.00 debit Transfer for Cash Spending Discover NaN NaN
2016-09-24 Amazon AMAZON PICKUP POINTS 877-345-0975 WATZP495DA69Q 9.83 debit Shopping Discover NaN NaN
2016-09-24 Internet Thank You INTERNET PAYMENT - THANK YOU 234.66 credit Credit Card Payment Discover NaN NaN

288 rows × 8 columns


In [51]:
to = dt.datetime.today()

In [139]:
categories = set(df['Category'])
print(categories)


{'Pharmacy', 'Public Transportation', 'Tuition', 'Gift', 'Advertising', 'Sporting Goods', 'Restaurants', 'Clothing', 'Transfer for Cash Spending', 'Rental Car & Taxi', 'Television', 'Groceries', 'Credit Card Payment', 'Air Travel', 'Doctor', 'Gym', 'Fast Food', 'Alcohol & Bars', 'Food & Dining', 'Shopping', 'Mortgage & Rent', 'Hair', 'Coffee Shops'}

In [273]:
getRangeExpenditure(df, to,to)


Out[273]:
0

In [258]:
def getTodayExpenditure(tab, today=dt.datetime.today()):
    '''gets amount of money spent toady'''
    if (today not in tab.index):
        return 0
    today_transactions = tab.loc[today.date()]
    return sum(today_transactions['Amount'])

In [79]:
test = getTodayExpenditure(df,test_date)
print("$",round(test,2))


$ 85.64

In [312]:
to


Out[312]:
datetime.datetime(2017, 9, 15, 23, 30, 27, 195687)

In [313]:
to - dt.timedelta(days=7)


Out[313]:
datetime.datetime(2017, 9, 8, 23, 30, 27, 195687)

In [263]:
a = [i for i in pd.date_range(to, to).values if i in df.index.values]

In [332]:
getFrequencies(df, test_date,test_date)


Out[332]:
{'Advertising': 0,
 'Air Travel': 0,
 'Alcohol & Bars': 0,
 'Clothing': 0,
 'Coffee Shops': 0,
 'Credit Card Payment': 0,
 'Doctor': 0,
 'Fast Food': 0,
 'Food & Dining': 0,
 'Gift': 0,
 'Groceries': 0,
 'Gym': 0,
 'Hair': 0,
 'Mortgage & Rent': 0,
 'Pharmacy': 0,
 'Public Transportation': 0,
 'Rental Car & Taxi': 77.650000000000006,
 'Restaurants': 7.9900000000000002,
 'Shopping': 0,
 'Sporting Goods': 0,
 'Television': 0,
 'Transfer for Cash Spending': 0,
 'Tuition': 0}

In [324]:
date_range = [i for i in pd.date_range(test_date, test_date).values if i in df.index.values]

In [326]:
transaction_range


Out[326]:
Description Original Description Amount Transaction Type Category Account Name Labels Notes
Date
2017-08-25 V A Cafe SQ *V&A CAFE BERKELEY CA0002305843011213890465 3.00 debit Restaurants Discover NaN NaN
2017-08-25 Lyft LYFT *RIDE FRI 12PM 855-280-0278 CA 11.69 debit Rental Car & Taxi Discover NaN NaN
2017-08-25 Lyft LYFT *RIDE FRI 12PM 855-280-0278 CA 35.11 debit Rental Car & Taxi Discover NaN NaN
2017-08-25 L Epi D SQ *L'EPI D'OR BAKERY CUPERTINO CA000115292150... 4.99 debit Restaurants Discover NaN NaN
2017-08-25 Lyft LYFT *RIDE FRI 10AM 855-280-0278 CA 30.85 debit Rental Car & Taxi Discover NaN NaN

In [268]:
def getRangeExpenditure(tab, date_start, date_end, category=None):
    '''returns the amount of money spent in date range'''
    date_range = [i for i in pd.date_range(date_start, date_end).values if i in tab.index.values]
    if (len(date_range)==0):
        return 0
    today_transactions = tab.loc[date_range]
    today_transactions.head()
    if (category==None):
        return sum(today_transactions['Amount'])
    else:
        return sum(today_transactions[today_transactions['Category']==category]['Amount'])

In [269]:
getRangeExpenditure(df, (dt.datetime.today()-dt.timedelta(days=60)).date(),dt.datetime.today().date(), 'Restaurants')


Out[269]:
129.41000000000003

In [330]:
def getFrequencies(tab, start_day, end_day, freq='daily'):
    date_range = [i for i in pd.date_range(start_day, end_day).values if i in tab.index.values]
    out = create_categories_map(tab)
    if (len(date_range)==0):
        return out
    transaction_range = tab.loc[date_range]
    out_val = transaction_range.groupby('Category')['Amount'].sum().to_dict()
    diff_days = (end_day - start_day).days
    if (diff_days==0):
        diff_days = 1
        
    if (freq == 'weekly'):
        r = diff_days/7
    elif (freq=='monthly'):
        r = diff_days/30
    elif (freq=='yearly'):
        r = diff_days/365
    else:
        r = diff_days
    for k in out_val:
        out_val[k] = out_val[k]/r
        out[k] = out_val[k]
    return out

In [331]:
def getFrequenciesCounts(tab, start_day, end_day, freq='daily'):
    date_range = [i for i in pd.date_range(start_day, end_day).values if i in tab.index.values]
    out = create_categories_map(tab)
    if (len(date_range)==0):
        return out
    transaction_range = tab.loc[date_range]
    out_val = transaction_range['Category'].value_counts().to_dict()
    diff_days = (end_day - start_day).days
    if (diff_days==0):
        diff_days = 1
        
    if (freq == 'weekly'):
        r = diff_days/7
    elif (freq=='monthly'):
        r = diff_days/30
    elif (freq=='yearly'):
        r = diff_days/365
    else:
        r = diff_days
    for k in out_val:
        out_val[k] = out_val[k]/r
        out[k] = out_val[k]
    return out

In [306]:
getFrequenciesCounts(df, x, to)


Out[306]:
{'Advertising': 0,
 'Air Travel': 0,
 'Alcohol & Bars': 0.047619047619047616,
 'Clothing': 0,
 'Coffee Shops': 0,
 'Credit Card Payment': 0.095238095238095233,
 'Doctor': 0,
 'Fast Food': 0,
 'Food & Dining': 0,
 'Gift': 0,
 'Groceries': 0.047619047619047616,
 'Gym': 0.047619047619047616,
 'Hair': 0,
 'Mortgage & Rent': 0,
 'Pharmacy': 0,
 'Public Transportation': 0,
 'Rental Car & Taxi': 0.33333333333333331,
 'Restaurants': 0.23809523809523808,
 'Shopping': 0,
 'Sporting Goods': 0,
 'Television': 0,
 'Transfer for Cash Spending': 0,
 'Tuition': 0}

In [201]:
def getOccurrencies(tab, start_day, end_day, freq='daily'):
    transaction_range = tab.loc[[i for i in pd.date_range(start_day, end_day).values if i in tab.index.values]]
    out = transaction_range['Category'].value_counts().to_dict()
    return out

In [335]:
(test_date+dt.timedelta(days=2)).weekday()


Out[335]:
6

In [154]:
def getFrequencyDate(time, freq='daily'):
    """returns the start and end dates based on the given frequency
    possible freq = 'daily', 'weekly', 'monthly', 'yearly' """
    if (freq=='weekly'):
        start = time - dt.timedelta(days=time.weekday())
        end = start + dt.timedelta(days=6)
    elif (freq=='monthly'):
        start = time.replace(day=1)
        start_day, end_day = calendar.monthrange(time.year,time.month)
        end = time.replace(day=end_day)
    elif (freq=='yearly'):
        start = time.replace(month=1).replace(day=1)
        end = time.replace(month=12).replace(day=31)
    else:
        start = time
        end = time
    return start, end

In [251]:
x = pd.to_datetime(to)

In [294]:
overall_f = full_category_frequencies(df,'weekly')

In [296]:
overall_f


Out[296]:
{'Advertising': 1.4957264957264957,
 'Air Travel': 1.8586894586894587,
 'Alcohol & Bars': 0.21678062678062676,
 'Clothing': 1.0916809116809116,
 'Coffee Shops': 1.2155270655270656,
 'Credit Card Payment': 99.655868945868932,
 'Doctor': 0.39886039886039881,
 'Fast Food': 5.5441595441595464,
 'Food & Dining': 1.5386039886039886,
 'Gift': 0.56757834757834758,
 'Groceries': 14.787948717948717,
 'Gym': 1.396011396011396,
 'Hair': 0.39886039886039881,
 'Mortgage & Rent': 0.99715099715099709,
 'Pharmacy': 0.63159544159544156,
 'Public Transportation': 3.2457264957264957,
 'Rental Car & Taxi': 5.3281766381766396,
 'Restaurants': 16.805384615384611,
 'Shopping': 33.906125356125344,
 'Sporting Goods': 1.9434472934472933,
 'Television': 3.4890313390313388,
 'Transfer for Cash Spending': 3.1908831908831905,
 'Tuition': 1.396011396011396}

In [293]:
def full_category_frequencies(tab, freq='Daily'):
    return getFrequencies(tab, min(tab.index), max(tab.index), freq)

In [297]:
def full_category_frequencies_counts(tab, freq='Daily'):
    return getFrequenciesCounts(tab, min(tab.index), max(tab.index), freq)

In [236]:
df[df['Description'] == 'Tea Cory Hall']


Out[236]:
Description Original Description Amount Transaction Type Category Account Name Labels Notes
Date
2017-04-25 Tea Cory Hall SQ *TEA 1 - CORY HALL BERKELEY CA0001152921507... 4.25 debit Fast Food Discover NaN NaN
2017-04-14 Tea Cory Hall SQ *TEA 1 - CORY HALL BERKELEY CA0002305843011... 4.00 debit Fast Food Discover NaN NaN
2017-04-03 Tea Cory Hall SQ *TEA 1 - CORY HALL BERKELEY CA0001152921507... 4.25 debit Fast Food Discover NaN NaN
2017-02-17 Tea Cory Hall SQ *TEA 1 - CORY HALL BERKELEY CA0002305843010... 4.25 debit Fast Food Discover NaN NaN
2017-01-27 Tea Cory Hall SQ *TEA 1 - CORY HALL BERKELEY CA0002305843010... 4.25 debit Fast Food Discover NaN NaN
2016-11-29 Tea Cory Hall SQ *TEA 1 - CORY HALL BERKELEY CA0001152921507... 4.00 debit Coffee Shops Discover NaN NaN
2016-11-21 Tea Cory Hall SQ *TEA 1 - CORY HALL BERKELEY CA0001152921507... 4.00 debit Fast Food Discover NaN NaN

In [249]:
df.index


Out[249]:
DatetimeIndex(['2017-09-09', '2017-09-09', '2017-09-10', '2017-09-10',
               '2017-09-09', '2017-09-08', '2017-08-31', '2017-08-31',
               '2017-08-29', '2017-08-29',
               ...
               '2016-10-14', '2016-10-07', '2016-10-01', '2016-09-30',
               '2016-09-26', '2016-09-26', '2016-09-25', '2016-09-25',
               '2016-09-24', '2016-09-24'],
              dtype='datetime64[ns]', name='Date', length=288, freq=None)

In [277]:
def create_categories_map(tab, label='Category'):
    cat_set = set(tab[label])
    out = dict()
    for c in cat_set:
        out[c] = 0
    return out

In [308]:
getFrequencies(df, pd.to_datetime("2017-08-01"),pd.to_datetime("2017-09-01"),'weekly')


Out[308]:
{'Advertising': 0,
 'Air Travel': 0,
 'Alcohol & Bars': 2.4545161290322577,
 'Clothing': 0,
 'Coffee Shops': 0,
 'Credit Card Payment': 172.73290322580644,
 'Doctor': 0,
 'Fast Food': 6.3858064516129032,
 'Food & Dining': 2.0254838709677419,
 'Gift': 0,
 'Groceries': 68.191290322580642,
 'Gym': 5.6451612903225801,
 'Hair': 0,
 'Mortgage & Rent': 0,
 'Pharmacy': 0,
 'Public Transportation': 0,
 'Rental Car & Taxi': 23.260322580645159,
 'Restaurants': 20.218709677419351,
 'Shopping': 25.213548387096772,
 'Sporting Goods': 0,
 'Television': 9.0299999999999994,
 'Transfer for Cash Spending': 0,
 'Tuition': 0}

In [307]:
full_category_frequencies(df, 'weekly')


Out[307]:
{'Advertising': 1.4957264957264957,
 'Air Travel': 1.8586894586894587,
 'Alcohol & Bars': 0.21678062678062676,
 'Clothing': 1.0916809116809116,
 'Coffee Shops': 1.2155270655270654,
 'Credit Card Payment': 99.655868945868917,
 'Doctor': 0.39886039886039881,
 'Fast Food': 5.5441595441595437,
 'Food & Dining': 1.5386039886039884,
 'Gift': 0.56757834757834758,
 'Groceries': 14.787948717948717,
 'Gym': 1.396011396011396,
 'Hair': 0.39886039886039881,
 'Mortgage & Rent': 0.99715099715099709,
 'Pharmacy': 0.63159544159544156,
 'Public Transportation': 3.2457264957264957,
 'Rental Car & Taxi': 5.3281766381766396,
 'Restaurants': 16.805384615384611,
 'Shopping': 33.906125356125365,
 'Sporting Goods': 1.9434472934472933,
 'Television': 3.4890313390313392,
 'Transfer for Cash Spending': 3.1908831908831905,
 'Tuition': 1.396011396011396}

In [299]:
df[df['Category']=='Credit Card Payment']


Out[299]:
Description Original Description Amount Transaction Type Category Account Name Labels Notes
Date
2017-08-31 Internet Thank You INTERNET PAYMENT - THANK YOU 225.61 credit Credit Card Payment Discover NaN NaN
2017-08-29 Internet Thank You INTERNET PAYMENT - THANK YOU 155.53 credit Credit Card Payment Discover NaN NaN
2017-08-24 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 383.82 credit Credit Card Payment Discover NaN NaN
2017-07-26 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 236.18 credit Credit Card Payment Discover NaN NaN
2017-07-17 Internet Thank You INTERNET PAYMENT - THANK YOU 375.09 credit Credit Card Payment Discover NaN NaN
2017-07-06 Internet Thank You INTERNET PAYMENT - THANK YOU 300.00 credit Credit Card Payment Discover NaN NaN
2017-06-19 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 200.00 credit Credit Card Payment Discover NaN NaN
2017-06-15 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 149.70 credit Credit Card Payment Discover NaN NaN
2017-06-10 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 390.83 credit Credit Card Payment Discover NaN NaN
2017-06-01 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 351.22 credit Credit Card Payment Discover NaN NaN
2017-05-18 Transfer from BofA Core Checking INTERNET PAYMENT - THANK YOU 406.59 credit Credit Card Payment Discover NaN NaN
2017-04-24 Internet Thank You INTERNET PAYMENT - THANK YOU 389.28 credit Credit Card Payment Discover NaN NaN
2017-03-21 Internet Thank You INTERNET PAYMENT - THANK YOU 159.88 credit Credit Card Payment Discover NaN NaN
2017-02-26 Internet Thank You INTERNET PAYMENT - THANK YOU 374.19 credit Credit Card Payment Discover NaN NaN
2016-12-23 Internet Thank You INTERNET PAYMENT - THANK YOU 254.90 credit Credit Card Payment Discover NaN NaN
2016-11-25 Internet Thank You INTERNET PAYMENT - THANK YOU 273.45 credit Credit Card Payment Discover NaN NaN
2016-10-23 Internet Thank You INTERNET PAYMENT - THANK YOU 136.10 credit Credit Card Payment Discover NaN NaN
2016-09-24 Internet Thank You INTERNET PAYMENT - THANK YOU 234.66 credit Credit Card Payment Discover NaN NaN

In [309]:
data = pd.read_excel('age.xls')

In [311]:
data.head()


Out[311]:
Table 3. Age of reference person: Average annual expenditures and characteristics, Consumer Expenditure Survey, 2011 Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4 Unnamed: 5 Unnamed: 6 Unnamed: 7 Unnamed: 8 Unnamed: 9
0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 Item All consumer units Under 25 years 25-34 years 35-44 years 45-54 years 55-64 years 65 years and older 65-74 years 75 years and older
2 Number of consumer units (in thousands) 122287 7743 20463 21699 24821 21688 25873 14079 11794
3 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
4 Consumer unit characteristics: ... NaN NaN NaN NaN NaN NaN NaN NaN NaN

In [ ]: