I have come across a bug in my code below. If the second element of my categories list is a capital letter then the resulting values of my data frame 'change_1_month_df' are NaN. If I use a lower case letter then the random numbers are correctly inserted. Any Ideas? Thanks
import pandas as pd
import numpy as np
dates = ['d1','d2']
categories = ['a','b']
sub_categories = ['f','g']
my_index = pd.MultiIndex.from_product([categories,sub_categories])
change_1_month_df = pd.DataFrame(index=my_index,columns=dates)
for a in categories:
for d in dates:
print a,d
if a == 'W':
None
else:
change_1_month_df.ix[a].ix['f'][d] = np.random.randn(1)
change_1_month_df.ix[a].ix['g'][d] = np.random.randn(1)
change_1_month_df