iris.pandas¶
Provide conversion to and from Pandas data structures.
See also: http://pandas.pydata.org/
In this module:
-
iris.pandas.
as_cube
(pandas_array, copy=True, calendars=None)[source]¶ Convert a Pandas array into an Iris cube.
- Parameters
pandas_array - A Pandas Series or DataFrame. (*) –
Kwargs:
- copy - Whether to make a copy of the data.
Defaults to True.
- calendars - A dict mapping a dimension to a calendar.
Required to convert datetime indices/columns.
Example usage:
as_cube(series, calendars={0: cf_units.CALENDAR_360_DAY}) as_cube(data_frame, calendars={1: cf_units.CALENDAR_GREGORIAN})
Note
This function will copy your data by default.
-
iris.pandas.
as_data_frame
(cube, copy=True)[source]¶ Convert a 2D cube to a Pandas DataFrame.
- Parameters
cube - The cube to convert to a Pandas DataFrame. (*) –
Kwargs:
- copy - Whether to make a copy of the data.
Defaults to True. Must be True for masked data and some data types (see notes below).
Note
This function will copy your data by default. If you have a large array that cannot be copied, make sure it is not masked and use copy=False.
Note
Pandas will sometimes make a copy of the array, for example when creating from an int32 array. Iris will detect this and raise an exception if copy=False.
-
iris.pandas.
as_series
(cube, copy=True)[source]¶ Convert a 1D cube to a Pandas Series.
- Parameters
cube - The cube to convert to a Pandas Series. (*) –
Kwargs:
- copy - Whether to make a copy of the data.
Defaults to True. Must be True for masked data.
Note
This function will copy your data by default. If you have a large array that cannot be copied, make sure it is not masked and use copy=False.