Converting values of a column to numpy array in Python

Viewed 41

I am reading Test.xlsx using pandas. In Test.xlsx,I want to convert elements of column N only into a numpy array. I present the expected output.

import pandas as pd
import numpy as np
file_loc = "Test.xlsx"
df = pd.read_excel(file_loc, index_col=None, na_values=['NA'], usecols="A,C:AA")
print(df)

The data is

N1      N
        
[4]     [1]
        
[5]     [2]
        
[8]     [3]
        
[10]    [4]
        
[12]    [5]

This is how it looks like in Excel

enter image description here

The expected output is

array([[1],[2],[3],[4],[5]])
0 Answers
Related