Since my edits are removed from @RikKraan post, here the answer as I mentioned in the comments to his reply.
First apply reset_index
to your series and then use to_numpy
, ie
series.reset_index().to_numpy()
Note, reset_index
converts the series to a dataframe.
As mentioned in the comments, the OP wants to store the IP as float. This can be done by removing the .
in the IP string and converting the index to float
before converting as mentioned above. Ie
series.index = series.index.str.replace('.','').astype(float)
series.reset_index().to_numpy()
This will give you your 2D numpy array with dtype float.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.