How to Convert Pandas Series to NumPy Array (With Examples)
https://www.statology.org/pandas-series-to-numpy-array16.06.2021 · The following code shows how to convert a pandas Series to a NumPy array: import pandas as pd import numpy as np #define series x = pd.Series( [1, 2, 5, 6, 9, 12, 15]) #convert series to NumPy array new_array = x.to_numpy() #view NumPy array new_array array ( [ 1, 2, 5, 6, 9, 12, 15]) #confirm data type type (new_array) numpy.ndarray
How to Convert Pandas Series to NumPy Array (With Examples)
www.statology.org › pandas-series-to-numpy-arrayJun 16, 2021 · import pandas as pd import numpy as np #define series x = pd. Series ([1, 2, 5, 6, 9, 12, 15]) #convert series to NumPy array new_array = x. to_numpy #view NumPy array new_array array([ 1, 2, 5, 6, 9, 12, 15]) #confirm data type type(new_array) numpy.ndarray Using the type() function, we confirm that the pandas Series has indeed been converted ...
pandas.Series.to_numpy — pandas 1.4.0 documentation
pandas.pydata.org › pandasJan 01, 2000 · When self contains an ExtensionArray, the dtype may be different. For example, for a category-dtype Series, to_numpy () will return a NumPy array and the categorical dtype will be lost. For NumPy dtypes, this will be a reference to the actual data stored in this Series or Index (assuming copy=False ). Modifying the result in place will modify ...