I'd like to create a list that stores all values of a single column. For example let's say my file has a column called 'FirstNames' and for the first 3 rows, the 'names' column has Merry, Pippin, Frodo.
I'd like to create a list that looks like [Merry, Pippin, Frodo]
I tried doing it like this:
import pandas as pd
data = pd.read_csv(".../TrainingFile.csv")
list = []
names = data['FirstNames']for i in range(0,2):list.append(names[i:i+1])print(list)
However the list does not only store the values in the cells and gives me an output like this:
Name: FirstName, dtype: object, 1 Merry
Name: FirstName, dtype: object, 2 Pippin
Name: FirstName, dtype: object, 3 Frodo
How can I change this? Thanks for the help.
Bonus: instead of range(0,2) how can I define the range so that it goes through the number of rows there are in the file?