Closed
Description
In [1]: import pandas as pd
In [2]: import rpy2
In [7]: import numpy as np
In [4]: arr = rpy2.robjects.IntVector(range(10))
In [5]: arr
Out[5]:
<IntVector - Python:0x102ed3908 / R:0x105a7c178>
[ 0, 1, 2, ..., 7, 8, 9]
In [6]: pd.Series(arr) # wrong behavior
Out[6]:
0 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
dtype: object
In [9]: np.array(arr)
Out[9]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int32)
In [10]: pd.Series(np.array(arr)) # correct behavior
Out[10]:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
dtype: int32
I guess this is a regression due to Series no longer being a subclass of np.ndarray. Not sure if numpy
exposes a catchall isarray
that does the checks.