# `pandas`_ is a popular data analysis tool, especially for working with tabular data. # You can convert your :py:class:`~hdmf.common.table.DynamicTable` to a # :py:class:`~pandas.DataFrame` using # :py:meth:`DynamicTable.to_dataframe <hdmf.common.table.DynamicTable.to_dataframe>`. # Accessing the table as a :py:class:`~pandas.DataFrame` provides you with powerful, # standard methods for indexing, selecting, and querying tabular data from `pandas`_. # This is the recommended method of reading data from your table. See also the `pandas indexing documentation`_. # Printing a :py:class:`~hdmf.common.table.DynamicTable` as a :py:class:`~pandas.DataFrame` # or displaying the :py:class:`~pandas.DataFrame` in Jupyter shows a more intuitive # tabular representation of the data than printing the # :py:class:`~hdmf.common.table.DynamicTable` object. # # .. _pandas: https://pandas.pydata.org/ # .. _`pandas indexing documentation`: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html df = table.to_dataframe() ############################################################################### # .. note:: # # Changes to the ``DataFrame`` will not be saved in the ``DynamicTable``. ############################################################################### # Converting the table from a pandas ``DataFrame`` # ------------------------------------------------ # If your data is already in a :py:class:`~pandas.DataFrame`, you can convert the # ``DataFrame`` to a :py:class:`~hdmf.common.table.DynamicTable` using the class method # :py:meth:`DynamicTable.from_dataframe <hdmf.common.table.DynamicTable.from_dataframe>`. table_from_df = DynamicTable.from_dataframe( name='my_table',
# `pandas`_ is a popular data analysis tool, especially for working with tabular data. # You can convert your :py:class:`~hdmf.common.table.DynamicTable` to a # :py:class:`~pandas.DataFrame` using # :py:meth:`DynamicTable.to_dataframe <hdmf.common.table.DynamicTable.to_dataframe>`. # Accessing the table as a :py:class:`~pandas.DataFrame` provides you with powerful, # standard methods for indexing, selecting, and querying tabular data from `pandas`_, # and is recommended. See also the `pandas indexing documentation`_. # Printing a :py:class:`~hdmf.common.table.DynamicTable` as a :py:class:`~pandas.DataFrame` # or displaying the :py:class:`~pandas.DataFrame` in Jupyter shows a more intuitive # tabular representation of the data than printing the # :py:class:`~hdmf.common.table.DynamicTable` object. # # .. _pandas: https://pandas.pydata.org/ # .. _`pandas indexing documentation`: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html df = table.to_dataframe() ############################################################################### # .. note:: # # Changes to the ``DataFrame`` will not be saved in the ``DynamicTable``. ############################################################################### # Converting the table from a pandas ``DataFrame`` # ------------------------------------------------ # If your data is already in a :py:class:`~pandas.DataFrame`, you can convert the # ``DataFrame`` to a :py:class:`~hdmf.common.table.DynamicTable` using the class method # :py:meth:`DynamicTable.from_dataframe <hdmf.common.table.DynamicTable.from_dataframe>`. table_from_df = DynamicTable.from_dataframe( name='my table',