Skip to content

datar.apis.tibble

module

datar.apis.tibble

Functions
  • add_column(_data, *args, _before, _after, _name_repair, _dtypes, **kwargs) (Any) Add one or more columns to an existing data frame.</>
  • add_row(_data, *args, _before, _after, **kwargs) (Any) Add one or more rows of data to an existing data frame.</>
  • as_tibble(df) (Any) Convert a DataFrame object to Tibble object</>
  • column_to_rownames(_data, var) (Any) Set rownames/index with one column, and remove it</>
  • deframe(x) (Any) Converts two-column data frames to a dictionaryusing the first column as name and the second column as value. If the input has only one column, a list. </>
  • enframe(x, name, value) (Any) Converts mappings or lists to one- or two-column data frames.</>
  • has_rownames(_data) (bool) Detect if a data frame has row names</>
  • remove_rownames(_data) (Any) Remove the index/rownames of a data frame</>
  • rowid_to_column(_data, var) (Any) Add rownames as a column</>
  • rownames_to_column(_data, var) (Any) Add rownames as a column</>
  • tibble(*args, _name_repair, _rows, _dtypes, _drop_index, _index, **kwargs) (Any) Constructs a data frame</>
  • tibble_row(*args, _name_repair, _dtypes, **kwargs) (Any) Constructs a data frame that is guaranteed to occupy one row.Scalar values will be wrapped with [] </>
  • tribble(*dummies, _name_repair, _dtypes) (Any) Create dataframe using an easier to read row-by-row layoutUnlike original API that uses formula (f.col) to indicate the column names, we use f.col to indicate them. </>
function

datar.apis.tibble.tibble(*args, _name_repair='check_unique', _rows=None, _dtypes=None, _drop_index=False, _index=None, **kwargs)

Constructs a data frame

Parameters
  • *args and
  • _name_repair (Union, optional) treatment of problematic column names:
    • - "minimal": No name repair or checks, beyond basic existence,
    • - "unique": Make sure names are unique and not empty,
    • - "check_unique": (default value), no name repair,
        but check they are unique,
    • - "universal": Make the names unique and syntactic
    • - a function: apply custom name repair
  • _rows (int, optional) Number of rows of a 0-col dataframe when args and kwargs arenot provided. When args or kwargs are provided, this is ignored.
  • _dtypes (optional) The dtypes for each columns to convert to.
  • _drop_index (bool, optional) Whether drop the index for the final data frame
  • _index (optional) The new index of the output frame
  • **kwargs A set of name-value pairs.
Returns (Any)

A constructed tibble

function

datar.apis.tibble.tribble(*dummies, _name_repair='minimal', _dtypes=None)

Create dataframe using an easier to read row-by-row layoutUnlike original API that uses formula (f.col) to indicate the column names, we use f.col to indicate them.

Parameters
  • *dummies Arguments specifying the structure of a dataframeVariable names should be specified with f.name
  • _dtypes (optional) The dtypes for each columns to convert to.
Examples
>>> tribble(>>>     f.colA, f.colB,
>>>     "a",    1,
>>>     "b",    2,
>>>     "c",    3,
>>> )
Returns (Any)

A dataframe

function

datar.apis.tibble.tibble_row(*args, _name_repair='check_unique', _dtypes=None, **kwargs)

Constructs a data frame that is guaranteed to occupy one row.Scalar values will be wrapped with []

Parameters
  • *args and
  • _name_repair (Union, optional) treatment of problematic column names:
    • - "minimal": No name repair or checks, beyond basic existence,
    • - "unique": Make sure names are unique and not empty,
    • - "check_unique": (default value), no name repair,
        but check they are unique,
    • - "universal": Make the names unique and syntactic
    • - a function: apply custom name repair
  • **kwargs A set of name-value pairs.
Returns (Any)

A constructed dataframe

function

datar.apis.tibble.as_tibble(df) → Any

Convert a DataFrame object to Tibble object

function

datar.apis.tibble.enframe(x, name='name', value='value')

Converts mappings or lists to one- or two-column data frames.

Parameters
  • x a list, a dictionary or a dataframe with one or two columns
  • name (optional) and
  • value (optional) value Names of the columns that store the names and values.If None, a one-column dataframe is returned. value cannot be None
Returns (Any)

A data frame with two columns if name is not None (default) orone-column otherwise.

function

datar.apis.tibble.deframe(x)

Converts two-column data frames to a dictionaryusing the first column as name and the second column as value. If the input has only one column, a list.

Parameters
  • x A data frame.
Returns (Any)

A dictionary or a list if only one column in the data frame.

function

datar.apis.tibble.add_row(_data, *args, _before=None, _after=None, **kwargs)

Add one or more rows of data to an existing data frame.

Aliases add_case

Parameters
  • _data Data frame to append to.
  • *args and
  • _before (optional) and
  • _after (optional) row index where to add the new rows.(default to add after the last row)
  • **kwargs Name-value pairs to add to the data frame.
Returns (Any)

The dataframe with the added rows

function

datar.apis.tibble.add_column(_data, *args, _before=None, _after=None, _name_repair='check_unique', _dtypes=None, **kwargs)

Add one or more columns to an existing data frame.

Parameters
  • _data Data frame to append to
  • *args and
  • _before (optional) and
  • _after (optional) Column index or name where to add the new columns(default to add after the last column)
  • _dtypes (optional) The dtypes for the new columns, either a uniform dtype or adict of dtypes with keys the column names
  • **kwargs Name-value pairs to add to the data frame
Returns (Any)

The dataframe with the added columns

function

datar.apis.tibble.has_rownames(_data)

Detect if a data frame has row names

Aliases has_index

Parameters
  • _data The data frame to check
Returns (bool)

True if the data frame has index otherwise False.

function

datar.apis.tibble.remove_rownames(_data)

Remove the index/rownames of a data frame

Aliases remove_index, drop_index, remove_rownames

Parameters
  • _data The data frame
Returns (Any)

The data frame with index removed

function

datar.apis.tibble.rownames_to_column(_data, var='rowname')

Add rownames as a column

Aliases index_to_column

Parameters
  • _data The data frame
  • var (optional) The name of the column
Returns (Any)

The data frame with rownames added as one column. Note that theoriginal index is removed.

function

datar.apis.tibble.rowid_to_column(_data, var='rowid')

Add rownames as a column

Parameters
  • _data The data frame
  • var (optional) The name of the column
Returns (Any)

The data frame with row ids added as one column.

function

datar.apis.tibble.column_to_rownames(_data, var='rowname')

Set rownames/index with one column, and remove it

Aliases column_to_index

Parameters
  • _data The data frame
  • var (optional) The column to conver to the rownames
Returns (Any)

The data frame with the column converted to rownames