4.1. Data Structure

4.1.1. TableData

class tabledata.TableData(table_name, header_list, row_list, dp_extractor=None)

Class to represent a table data structure.

Parameters:
  • table_name (str) – Name of the table.
  • header_list (list) – Table header names.
  • record_list (list) – Table data records.
as_dataframe()
Returns:

Table data as a pandas.DataFrame instance.

Return type:

pandas.DataFrame

Sample Code:
from tabledata import TableData

TableData(
    table_name="sample",
    header_list=["a", "b"],
    row_list=[[1, 2], [3.3, 4.4]]
).as_dict()
Output:
     a    b
0    1    2
1  3.3  4.4
Dependency Packages:
 
as_dict()
Returns:

Table data as a dict instance.

Return type:

dict

Sample Code:
from tabledata import TableData

TableData(
    table_name="sample",
    header_list=["a", "b"],
    row_list=[[1, 2], [3.3, 4.4]]
).as_dict()
Output:
{'sample': [OrderedDict([('a', 1), ('b', 2)]),
  OrderedDict([('a', 3.3), ('b', 4.4)])]}
dp_extractor
equals(other, is_strict=False)
filter_column(pattern_list=None, is_invert_match=False, is_re_match=False, pattern_match=<PatternMatch.OR: 0>)
static from_dataframe(dataframe, table_name=u'')

Initialize TableData instance from a pandas.DataFrame instance.

Parameters:
  • dataframe (pandas.DataFrame) –
  • table_name (str) – Table name to create.
has_value_dp_matrix
header_dp_list
header_list
Returns:Table header names.
Return type:list
in_tabledata_list(other, is_strict=False)
is_empty()
Returns:True if the data header_list or value_matrix is empty.
Return type:bool
is_empty_header()
Returns:True if the data header_list is empty.
Return type:bool
is_empty_record()

Depricated

is_empty_rows()
Returns:True if the tabular data has no rows.
Return type:bool
num_columns
num_rows
Returns:Number of rows in the tabular data. None if the row_list is neither list nor tuple.
Return type:int
row_list
Returns:Table rows.
Return type:list
table_name
Returns:Name of the table.
Return type:str
validate_rows()
Raises:ValueError
value_dp_matrix
Returns:DataProperty for table data.
Return type:list
value_matrix
Returns:Table data rows.
Return type:list