Default conversions#
This page list the default conversions between R and Python objects.
Basic types#
The conversion of basic types is performed directly by the
convert() and convert_python_to_r_data() functions
(or the underlying Converter and ConverterFromPythonToR).
Thus, changing the conversion for basic types currently requires creating a custom converter class.
The default converters perform the following conversions:
R type |
Python type |
|---|---|
builtin function |
|
bytecode |
|
char (internal) |
|
closure |
|
complex |
|
environment |
|
expression |
|
external pointer |
|
integer |
|
language |
|
list / vector |
|
logical (boolean) |
|
missing argument |
|
NULL |
|
real |
|
reference |
The referenced value, that is, an object already converted. |
S4 object |
|
special function |
|
string |
|
symbol |
|
Custom classes#
In addition, R objects containing a “class” attribute, or Python objects not listed above, are passed to an R-to-Python or Python-to-R constructor function, respectively. When the “class” attribute contains several class names, these are tried in order. A dictionary of constructor functions can be supplied to the converters as exemplified in Converting between R and Python classes. The default constructor dictionaries perform the following conversions:
R class |
Python class |
|---|---|
data.frame |
|
factor |
|
ordered |
|
srcfile |
|
srcfilecopy |
|
srcref |
|
ts |