0

I have a csv file. One of its column name is mpg. I am reading file in this way.

data = pd.read_csv('auto-mpg.csv')   
var_1 = data['mpg']  
train_y = numpy.asarray(var_1)  

How can I copy the data of var1 data into train_y array?

Bierbarbar
  • 1,399
  • 15
  • 35

1 Answers1

0

New: OK Missed that it was a training array, this likely is the same question, How do I create test and train samples from one dataframe with pandas?

Old: Some sample data would help, but you can use pandas to rip and format the data on the first pass. this is what I imagine you expect it to work like.

import pandas as pd
import numpy

    df = pd.read_csv('auto-mpg.csv',converters={"mpg": lambda x: numpy.asarray(x)})
    train_y = df.mpg
Reroute
  • 265
  • 1
  • 9