Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12261

Vectorized way to copy elements from pandas Series to python built-in array

$
0
0

Is there a vectorized way to copy elements from a pandas Series to a python built-in array? For example:

from array import arrayimport pandas as pds = pd.Series(range(0, 10, 2)); s += 0.1a = array('d', [0.0]*10)# I am looking for a vectorized equivalent of the below line:for n,x in enumerate(s): a[n] = x

In my case, the array is given as a memory buffer to an external code, which saves the array address and only re-reads array values upon each call. So, I cannot recreate the array and need to only replace its values as quickly as possible.

Thank you very much for your help!


Viewing all articles
Browse latest Browse all 12261

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>