Python error

Status
Not open for further replies.
import numpy as np
import pandas as pd
from sklearn import tree
from sklearn import preprocessing as pp

#read train dataset from CSV input file
train_dataset = pd.read_csv("./Q2_train.csv")
train_data = train_dataset[["Tear Production Rate","Sex","Age","Spectacle Prescription","Astigmatism"]]
train_label = train_dataset.Recommendation

#data preprocessing of train_data
le = pp.LabelEncoder()
le.fit(train_data["Tear Production Rate"])
train_data["Tear Production Rate"] = le.transform(train_data["Tear Production Rate"])
print(train_data)

The above gave me what I wanted but came with the warning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

But I have no idea how to do this...?! Any advice?
 

m3ch3

Wise, Aged Ars Veteran
178
While I don't feel entirely qualified to answer this, I will post since the thread seems to be quiet. Hopefully you've figured it out by now anyway. Stackoverflow says that python is overly sensitive and providing a warning that you are overwriting a piece of data. If it's doing what you want, you can leave it.
This page may be able to further clarify:
https://stackoverflow.com/questions/206 ... -in-pandas
 
Status
Not open for further replies.