python - Pb converting a list of pandas.Series into a numpy array of pandas.Series -
i convert list of pandas.series numpy array of pandas.series. when call array constructor, converting series.
>>> l = [series([1,2,3]),series([4,5,6])] >>> np.array(l) array([[1, 2, 3], [4, 5, 6]], dtype=int64)
my list small (~10 elements), performances issues ( https://stackoverflow.com/questions/22212777/python-pandas-small-series-performances?noredirect=1#comment33725521_22212777 ) avoid create pandas.dataframe. there easy workaround?
thanks in advance
you should set dtype
of array when assign it:
l = [pd.series([1,2,3]),pd.series([4,5,6])] np.array(l, dtype=pd.series)
though raises question: why want ndarray of series, , not ndarray of contents of series?
Comments
Post a Comment