Example #1
0
    def test_frame_getitem_setitem_multislice(self):
        levels = [['t1', 't2'], ['a','b','c']]
        labels = [[0,0,0,1,1], [0,1,2,0,1]]
        midx = MultiIndex(labels=labels, levels=levels, names=[None, 'id'])
        df = DataFrame({'value':[1,2,3,7,8]}, index=midx)

        result = df.ix[:,'value']
        assert_series_equal(df['value'], result)

        result = df.ix[1:3,'value']
        assert_series_equal(df['value'][1:3], result)

        result = df.ix[:,:]
        assert_frame_equal(df, result)

        result = df
        df.ix[:, 'value'] = 10
        result['value'] = 10
        assert_frame_equal(df, result)

        df.ix[:,:] = 10
        assert_frame_equal(df, result)
Example #2
0
    def test_frame_getitem_setitem_multislice(self):
        levels = [["t1", "t2"], ["a", "b", "c"]]
        labels = [[0, 0, 0, 1, 1], [0, 1, 2, 0, 1]]
        midx = MultiIndex(labels=labels, levels=levels, names=[None, "id"])
        df = DataFrame({"value": [1, 2, 3, 7, 8]}, index=midx)

        result = df.ix[:, "value"]
        assert_series_equal(df["value"], result)

        result = df.ix[1:3, "value"]
        assert_series_equal(df["value"][1:3], result)

        result = df.ix[:, :]
        assert_frame_equal(df, result)

        result = df
        df.ix[:, "value"] = 10
        result["value"] = 10
        assert_frame_equal(df, result)

        df.ix[:, :] = 10
        assert_frame_equal(df, result)
Example #3
0
# 	for name in fund_names:
# 		for jj in range(len(funds[name][ii])):
# 			df[name][jj]=funds[name][ii][jj]

# 	for area in linspace:
# 		plt.figure(counter)
# 		counter+=1
# 		df.ix[:,area[0]:area[1]].plot(legend=False,ylim=(-0.02,0.02))
# 		png_name = beta_names[ii]+'from_'+str(area[0])+'to_'+str(area[1])+'.png'
# 		plt.savefig('beta_'+str(ii+1)+'/'+png_name,dpi=100)
# 		plt.close()


plt.figure(counter)
df = DataFrame(np.zeros((len(ind),len(fund_names))))
df.ix[:,:]=np.NaN
df.index=ind
df.columns=fund_names
for name in fund_names:
	for jj in range(len(alphas[name])):
		df[name][jj]=alphas[name][jj]

for area in linspace:
	plt.figure(counter)
	counter+=1
	df.ix[:,area[0]:area[1]].plot(legend=False,ylim=(-0.03,0.03))
	png_name = 'alpha'+'from_'+str(area[0])+'to_'+str(area[1])+'ma6.png'
	plt.savefig('alpha/'+png_name,dpi=100)
	plt.close()