I have a pandas dataframe that contains multiple columns and rows.
Below is just one row of my dataframe, where the first columns are the headers and the second column is the data.
I used full_df.iloc[0] to extract the first row of data.
full_df is the name of my pandas dataframe.
year 2015.0
month 1.0
day 1.0
hour 0.0
minute 0.0
WDIR 13.0
WSPD 5.6
GST 6.9
WVHT 99.0
DPD 99.0
APD 99.0
MWD 999.0
PRES 1026.1
ATMP 11.4
WTMP 17.8
DEWP 999.0
VIS 99.0
TIDE 99.0
Name: 0, dtype: float64
How can I get this data into a numpy array?
I tried doing the following:
gfg = pd.Series(full_df.iloc[0])
gfg.to_numpy
But I get the following error:
AttributeError: 'Series' object has no attribute 'to_numpy'
you can just try:
import numpy as np
gfg = pd.Series(full_df.iloc[0])
np.array(gfg)
Is it what you want?
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.