0

I have this code:

df = pd.read_csv("Fatalities.csv")
training_data, testing_data = train_test_split(df, test_size=0.75, random_state=20)
df["fatal"] = pd.to_numeric(df["fatal"], downcast="float")
Y = training_data["fatal"] 
X = training_data.drop(columns=["fatal"])
reg =  linear_model.LinearRegression().fit(X,Y)

I keep getting could not convert string to float. But if I run only the 3rd line and print(df.dtrypes) it shows my "fatal" variable as float.

pigrammer
  • 2,603
  • 1
  • 11
  • 24
jsemphrrt
  • 1
  • 1

0 Answers0