Error in Python script “Expected 2D array, got 1D array instead:”?

后端 未结 9 743
执念已碎
执念已碎 2020-11-30 01:29

I\'m following this tutorial to make this ML prediction:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style

style.use(\"ggplot\         


        
9条回答
  •  隐瞒了意图╮
    2020-11-30 02:01

    With one feature my Dataframe list converts to a Series. I had to convert it back to a Dataframe list and it worked.

    if type(X) is Series:
        X = X.to_frame()
    

提交回复
热议问题