示例#1
0
 def addContainer(self, nwbfile):
     nwbfile.units = DynamicTable.from_dataframe(pd.DataFrame({
         'a': [1, 2, 3],
         'b': ['4', '5', '6']
     }), 'units')
     # reset the thing
     self.container = nwbfile.units
示例#2
0
 def setUpContainer(self):
     # this will get ignored
     return DynamicTable.from_dataframe(
         pd.DataFrame({
             'a': [[1, 2, 3], [1, 2, 3], [1, 2, 3]],
             'b': ['4', '5', '6']
         }), 'test_table')
示例#3
0
    def test_from_dataframe(self):
        df = pd.DataFrame({
            'foo': [1, 2, 3, 4, 5],
            'bar': [10.0, 20.0, 30.0, 40.0, 50.0],
            'baz': ['cat', 'dog', 'bird', 'fish', 'lizard']
        }).loc[:, ('foo', 'bar', 'baz')]

        obtained_table = DynamicTable.from_dataframe(df, 'test')
        self.check_table(obtained_table)
示例#4
0
    def test_pandas_roundtrip(self):
        df = pd.DataFrame({
            'a': [1, 2, 3, 4],
            'b': ['a', 'b', 'c', '4']
        }, index=pd.Index(name='an_index', data=[2, 4, 6, 8]))

        table = DynamicTable.from_dataframe(df, 'foo')
        obtained = table.to_dataframe()

        assert df.equals(obtained)
示例#5
0
def test_show_dynamic_table():
    d = {"col1": [1, 2], "col2": [3, 4]}
    dt = DynamicTable.from_dataframe(df=pd.DataFrame(data=d),
                                     name="Test Dtable",
                                     table_description="no description")
    show_dynamic_table(dt)
示例#6
0
    def test_auto_ragged_array(self):

        df = pd.DataFrame({'a': [[1], [1, 2]]})
        df2 = DynamicTable.from_dataframe(df, name='test').to_dataframe()
        df.equals(df2)
示例#7
0
def test_show_dynamic_table():
    d = {'col1': [1, 2], 'col2': [3, 4]}
    dt = DynamicTable.from_dataframe(df=pd.DataFrame(data=d),
                                     name='Test Dtable',
                                     table_description='no description')
    show_dynamic_table(dt)