I have the below data in a csv and I am trying to create a dataframe of 1 column by selecting each column from the csv at a time.
sv_m1 rev ioip
0 15.31 40
0 64.9 0
0 18.36 20
0 62.85 0
0 10.31 20
0 12.84 10
0 69.95 0
0 32.81 20
The list that I get, the first value is the column name and remaining are values.
input_file = open('df_seg_sample.csv', 'r')
c_reader = csv.reader(input_file, delimiter=',')
#Read column
column = [x[1] for x in c_reader]
label = column[0]
column = column[1:]
df_column = pd.DataFrame.from_records(data = column,columns = label)
However this gives me an error:
TypeError: Index(...) must be called with a collection of some kind, 'sv_m1' was passed
core is actually the column name.
How can I create this df? The column name of the df will be the first element in the list and all other items in the list will be the column values.
The reason for not using pandas.read_csv is: The dataframe is huge and hogs up a lot of memory. So I want to read in a column at a time, do some processing and write it to another csv.