Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams from sklearn.preprocessing import LabelEncoder from sklearn.cross_validation import StratifiedShuffleSplit train = pd.read_csv('..\input\train.csv') test = pd.read_csv('..\input\test.csv') def encode(train, test): le = LabelEncoder().fit(train.species) labels = le.transform(train.species) classes = list(le.classes_) test_ids = test.id train = train.drop(['species', 'id'], axis=1) test = test.drop(['id'], axis=1) return train, labels, test, test_ids, classes train, labels, test, test_ids, classes = encode(train, test) train.head(5)
NameError                                 
Traceback (most recent call last) <ipython-input-10-08166fb1df95> in <module>()
     10     return train, labels, test, test_ids, classes
---> 12 train, labels, test, test_ids, classes = encode(train, test)
     13 train.head(5)
NameError: name 'train' is not defined
                can you post the full stacktrace? and this won't work as you want: pd.read_csv('..\input\train.csv') actually reads '..\input<tabulation char>rain.csv'
– Jean-François Fabre
                Sep 15, 2016 at 19:22
                Okay.train = pd.read_csv(r'C:\Users*****\PycharmProjects\kaggle\leaf\input\train.csv') test=pd.read_csv(r'C:\Users*****\PycharmProjects\kaggle\leaf\input\test.csv')
– tony2046
                Sep 15, 2016 at 19:27
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.