UserSpace.new_cells_from_pandas

UserSpace.new_cells_from_pandas(obj, cells=None, param=None)[source]

Create new cells from Pandas Series or DataFrame object.

Return new cells created from Pandas Series or DataFrame object passed as obj.

obj can either be a Series or a DataFrame. If obj is a Series, a single cells is created. The cells’ name is taken from the Series’ name, but can be overwritten if a valid name is passed as cells.

If obj is a DataFrame, a cells is created for each column. The cells’ names can be overwritten by a sequence of valid names passed as cells

Keys and values of the cells data are copied from obj.

obj can have MultiIndex. If the index(es) of obj has/have name(s), the parameter name(s) of the cells is/are set to the name(s), but can be overwritten by param parameter. If the index(es) of obj has/have no name(s), and param is not given, error is raised. Error is raised when obj has duplicated indexes.

Parameters
  • obj – Pandas Series or DataFrame object

  • cells (str, optional) – cells name. If obj has a valid name and this cells is not given, the name is used. If obj does not have a name and this cells is not given, the cells is named automatically.

  • param – sequence of strings to set parameter name(s). A single string can also be passed to set a single parameter name when obj has a single level index (i.e. not MultiIndex).

Returns

New cells if obj is a Series, CellsView if obj is DataFrame.

See also

new_space_from_pandas(): Create Spaces and Cells from DataFrame or Series.