0

I'm trying to do a very simple thing - to get a pandas dataframe column and use it as a vector. I'm new to python. In R, using dplyr, I'd do:

my_data_frame %>% pull(my_favourite_column)

How to achieve this in Python? I tried these:

import pandas as pd
test = pd.read_csv(os.path.join(PATH_TO_FILE, 'test.csv'))

my_col = as.vector(test['my_column'])
my_col = test[['my_column']]
my_col = test.my_column.to_string()

but no success.

Jakub Małecki
  • 483
  • 4
  • 14
  • 2
    duplicate of a duplicate >>> https://stackoverflow.com/questions/23748995/pandas-dataframe-column-to-list – BlackMath Aug 05 '21 at 10:11

1 Answers1

1
my_col = test['my_column'].tolist()

yuanzz
  • 1,359
  • 12
  • 15