3

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.

MB-F
  • 22,770
  • 4
  • 61
  • 116
LF. Sun
  • 33
  • 1
  • 1
  • 4
  • I would suggest going through pandas documentation, taking the first Pandas tutorials, etc. – rll Feb 29 '16 at 14:48
  • I don't think this is a duplicate. The linked question does not really answer how to access columns. (There may be other questions/answers that do so, though) – MB-F Feb 29 '16 at 14:52
  • The mentioned question/solution couldn't help me really. But thank you all for the discussion. I am just beginning to learn python since this week. I will read the Pandas Tutorials as the next step. – LF. Sun Mar 01 '16 at 09:17
  • df.to_numpy() -> this should do the trick – Tanmoy Jun 07 '22 at 04:25

2 Answers2

1

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()
Francesco Nazzaro
  • 2,688
  • 11
  • 20
0

Column names can be used as indices such as data['10V'].

You should really check out the Pandas tutorial.

MB-F
  • 22,770
  • 4
  • 61
  • 116