datascience.tables.Table.from_df

classmethod Table.from_df(df, keep_index=False)[source]

Convert a Pandas DataFrame into a Table.

Args:

df – Pandas DataFrame utilized for creation of Table

keep_index – keeps the index of the DataFrame and turns it into a column called index in the new Table

Returns:

a table from Pandas Dataframe in argument

Example:

>>> sample_DF = pandas.DataFrame(
...             data = zip([1,2,3],['a','b','c'],['data1','data2','data3']),
...             columns = ['column1','column2','column3']
...             )
>>> sample_DF
   column1 column2 column3
0        1       a   data1
1        2       b   data2
2        3       c   data3
>>> t = Table().from_df(sample_DF)
>>> t
column1 | column2 | column3
1       | a       | data1
2       | b       | data2
3       | c       | data3