def test__df_index_name_with_unnamed_multi_index(self, pd): arrays = [ np.array(['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux']), np.array(['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']) ] df = pd.DataFrame(np.random.randn(8, 4), index=arrays) assert df.index.names == [None, None] assert ColumnDataSource._df_index_name(df) == "index"
def test__df_index_name_with_named_multi_index(self): data = io.StringIO(u''' Fruit,Color,Count,Price Apple,Red,3,$1.29 Apple,Green,9,$0.99 Pear,Red,25,$2.59 Pear,Green,26,$2.79 Lime,Green,99,$0.39 ''') df = pd.read_csv(data).set_index(['Fruit', 'Color']) assert df.index.names == ['Fruit', 'Color'] assert ColumnDataSource._df_index_name(df) == "Fruit_Color"
def test__df_index_name_with_named_multi_index(self, pd): data = io.StringIO(u''' Fruit,Color,Count,Price Apple,Red,3,$1.29 Apple,Green,9,$0.99 Pear,Red,25,$2.59 Pear,Green,26,$2.79 Lime,Green,99,$0.39 ''') df = pd.read_csv(data).set_index(['Fruit', 'Color']) assert df.index.names == ['Fruit', 'Color'] assert ColumnDataSource._df_index_name(df) == "Fruit_Color"
def test__df_index_name_with_unnamed_index(self, pd): df = pd.DataFrame(dict(a=[10], b=[20], c=[30])) assert ColumnDataSource._df_index_name(df) == "index"
def test__df_index_name_with_unnamed_multi_index(self): arrays = [np.array(['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux']), np.array(['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two'])] df = pd.DataFrame(np.random.randn(8, 4), index=arrays) assert df.index.names == [None, None] assert ColumnDataSource._df_index_name(df) == "index"
def test__df_index_name_with_unnamed_index(self): df = pd.DataFrame(dict(a=[10], b=[20], c=[30])) assert ColumnDataSource._df_index_name(df) == "index"
def test__df_index_name_with_named_index(self): df = pd.DataFrame(dict(a=[10], b=[20], c=[30])).set_index('c') assert ColumnDataSource._df_index_name(df) == "c"
def test__df_index_name_with_named_index(self, pd): df = pd.DataFrame(dict(a=[10], b=[20], c=[30])).set_index('c') assert ColumnDataSource._df_index_name(df) == "c"