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.

4
  • I would suggest going through pandas documentation, taking the first Pandas tutorials, etc. Commented Feb 29, 2016 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) Commented Feb 29, 2016 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. Commented Mar 1, 2016 at 9:17
  • df.to_numpy() -> this should do the trick Commented Jun 7, 2022 at 4:25

2 Answers 2

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()
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much for the solution. It is what I wanted!
It's done. It was my first question. Now I understand the process here;-)
0

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

You should really check out the Pandas tutorial.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.