Open DavisVaughan opened 6 years ago
Overall, I'm a fan of the second proposal. Given this:
Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.). The axis labels are collectively referred to as the index.
https://pandas.pydata.org/pandas-docs/stable/dsintro.html
I think it's "close enough" to say that a Series object is an indexable array, and so setting the names (while preserving other metadata) is the best way forward. In other words, we should convert them roughly the same as we do NumPy arrays, while attempting to preserve relevant object metadata.
In addition, since I think it's common to have Series objects live as part of a Pandas DataFrame, it would be more natural to treat them as vectors rather than one-column DataFrames.
Pandas Series can contain valuable metadata like an Index and a Name. Currently all of this is lost because of the use of
py_to_r(x$values)
in the conversion. (Note that Indices are required and Names are optional for Series)If you wanted to keep this information, I see 2 options.
1) Treat a Series as a 1 column data frame.
Resulting in:
2) Treat the Series like a named vector
py_to_r.pandas.core.frame.DataFrame
into it's own function for use here, but it should "just work" for Series too.Resulting in: