I have a list of names in one column of a csv file. I'm trying to make this into a list in python that looks like
list = ['name1', 'name2', 'name3']
and so on.
I have the following
import pandas as pd
export = pd.read_csv('Top100.csv', header=None)
but I can't figure out how to pull out the information and put it into a list format.
The below is applicable if your data is in a vertical column
export = pd.read_csv('Top100.csv', header=None)
export.values.T[0].tolist()
The .T in this transposes the values, as normally pandas is row oriented. Then you take the [0] index because Pandas reads excel or csv sheets in as a matrix, even if there's only a single column. Call the tolist() method on it and you're done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With