How to solve NameError: name 'data' is not defined

import pandas as pd

import numpy as np

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import StandardScaler

from sklearn.svm import SVC

from sklearn.metrics import accuracy_score

from sklearn.neighbors import KNeighborsClassifier

from sklearn.naive_bayes import GaussianNB

from sklearn.ensemble import RandomForestClassifier
file = ‘/content/data1.csv’

df = pd.read_csv(file)

df_encoded = pd.get_dummies(df, drop_first=True)
vals = [val[0:-1] for val in data[‘data’]]

labels = [lab[-1] for lab in data[‘data’]]
NameError Traceback (most recent call last)
in <cell line: 1>()
----> 1 vals = [val[0:-1] for val in data[‘data’]]
2 labels = [lab[-1] for lab in data[‘data’]]

i am gerring these two error how to solve it i am biggginer

This is not a streamlit issue but, in a line you wrote

vals = [val[0:-1] for val in data[‘data’]]
labels = [lab[-1] for lab in data[‘data’]]

But where is this list called data defined in your code?

also this is not the correct place to post this issue, please post it under :balloon: Using Streamlit

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.