Skip to content

Instantly share code, notes, and snippets.

@Jojozzc
Created December 2, 2018 12:45
Show Gist options
  • Save Jojozzc/bffa75177985eebe28b2716ea46a4f5c to your computer and use it in GitHub Desktop.
Save Jojozzc/bffa75177985eebe28b2716ea46a4f5c to your computer and use it in GitHub Desktop.
load data from csv file use pandas
import pandas as pd
import numpy as np
def load_train_data(path='inputFiles/train.csv'):
x = []
y = []
data = pd.read_csv(path)
data = data.values
data_num = len(data)
for i in range(0, data_num):
line = data[i]
label = int(line[len(line) - 1])
row_data = line[1:(len(line) - 1)]
x.append(np.array(row_data))
y.append(label)
return np.array(x), np.array(y)
@Jojozzc
Copy link
Author

Jojozzc commented Dec 2, 2018

Created when joined one data contest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment