Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert the dataframe to array in python? [duplicate]

I have read data from excel like the followings:

import numpy as np
import pandas as pd

Location = r'C:\temp\test.xlsx'
data = pd.read_excel(Location, '4bar',     header=0,     parse_cols=0)

data
Out[80]: 
             10V        11V
0     -60.531006 -31.539307
1      -2.547607 -30.776367
2      58.487549  48.569336
3      72.220459  74.509277
4      64.591064  74.509277
5      54.672852  60.013428

I want to put the column '10V' and '11V' into two arrays. In order to process the data with filter coefficients. But I don't know how to copy column to array or how to access/operate the element directly in DataFrame?

Can anyone give me a hint? Thank you.

like image 318
LF. Sun Avatar asked Mar 14 '26 07:03

LF. Sun


1 Answers

you can use as_matrix function.

import pandas as pd

Location = r'C:\temp\test.xlsx'
data = pd.read_excel(Location, '4bar', header=0, parse_cols=0)
numpy_data = data.as_matrix()
like image 195
Francesco Nazzaro Avatar answered Mar 15 '26 19:03

Francesco Nazzaro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!