Answers for "pandas series to numpy array"

0

get pandas dataframe as numpy array

>>> df = pd.DataFrame({"A": [1, 2], "B": [3.0, 4.5]})
>>> df.to_numpy()
array([[1. , 3. ],
       [2. , 4.5]])
Posted by: Guest on May-02-2020
0

convert a pandas df to a numpy array

x = df.to_numpy()
x
Posted by: Guest on August-02-2021
0

pandas series to numpy array

ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
>>> ser.to_numpy()
array(['a', 'b', 'a'], dtype=object)
Posted by: Guest on November-15-2021
0

pandas series to numpy array

ser.to_numpy(dtype="datetime64[ns]")
... 
array(['1999-12-31T23:00:00.000000000', '2000-01-01T23:00:00...'],
      dtype='datetime64[ns]')
Posted by: Guest on November-15-2021

Code answers related to "pandas series to numpy array"

Python Answers by Framework

Browse Popular Code Answers by Language