chaco.data_frame_plot_data module

Defines DataFramePlotData.

class chaco.data_frame_plot_data.DataFramePlotData

Bases: chaco.abstract_plot_data.AbstractPlotData

A PlotData implementation class that handles a DataFrame.

By default, it doesn’t allow its input data to be modified by downstream Chaco components or interactors. The index is available as data unless there is a column named ‘index’, in which case that column masks the DataFrame index. (Rename that column if the DataFrame index must be accessible.)

data_frame = Instance("pandas.core.frame.DataFrame")

The DataFrame backing this object.

del_data(name)

Deletes the column specified by name, or raises a KeyError if the named column does not exist.

get_data(name)

Returns the array associated with name.

Implements AbstractDataSource.

list_data()

Returns a list of the names of the columns of the DataFrame. The name ‘index’ is added to this unless there is a column named ‘index’.

set_data(name, new_data, generate_name=False)

Sets the specified index or column as the value for either the specified name or a generated name.

If the instance’s writable attribute is True, then this method sets the data associated with the given name to the new value, otherwise it does nothing.

Parameters
  • name (string) – The name of the array whose value is to be set.

  • new_data (array) – The array to set as the value of name.

  • generate_name (Boolean) – If True, a unique name of the form ‘seriesN’ is created for the array, and is used in place of name. The ‘N’ in ‘seriesN’ is one greater the largest N already used.

Returns

Return type

The name under which the array was set.

set_selection(name, selection)

Overrides AbstractPlotData to do nothing and not raise an error.

update_data(*args, **kwargs)

Sets the specified column or index as the value for either the specified name or a generated name.

Implements AbstractPlotData’s update_data() method. This method has the same signature as the dictionary update() method.

writable = True

Consumers can write data to this object (overrides AbstractPlotData).