Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert ndarray to series in python

I have a ndarray like this one:

In [75]:
z_r
Out[75]:
array([[ 0.00909254],
       [ 0.02390291],
       [ 0.02998752]])

In here, I want to ask how to convert those things to series, the desired output is like this:

0   0.00909254
1   0.02390291
2   0.02998752
like image 267
markov zain Avatar asked Jun 01 '15 00:06

markov zain


2 Answers

You can use this one:

my_list = map(lambda x: x[0], z_r)
ser = pd.Series(my_list)
In [86]:
ser
Out[86]:
0      0.009093
1      0.023903
2      0.029988

Actually, your question is how to convert to series ^^

like image 200
Priagung Khusumanegara Avatar answered Oct 30 '22 16:10

Priagung Khusumanegara


pd.Series(my_ndarray)

no need to convert it first to a list then to series.

like image 11
Cohensius Avatar answered Oct 30 '22 16:10

Cohensius