Python Forum
Line charts error "'isnan' not supported for the input types," - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Line charts error "'isnan' not supported for the input types," (/thread-28515.html)



Line charts error "'isnan' not supported for the input types," - issac_n - Jul-22-2020

I intent to create line charts from df.

class MyTableWidget(QWidget):
    
    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.layout = QVBoxLayout(self)
        self.tabs = QTabWidget()
        self.tab2 = QWidget()
        self.tabs.resize(300,100)
        self.tabs.addTab(self.tab2,"Tab A")
        self.tab2.layout = QVBoxLayout(self)
        
        G1 = qtg.PlotWidget()
        G2 = qtg.PlotWidget()
        G2.setBackground('w')
        G2.showGrid(x=True, y= True)
        hour = [1,2,3,4,5,6,7,8,9,10]
        temperature = [30,32,34,32,33,31,29,32,35,45]
        pen = qtg.mkPen('r')
        G2.plot(hour,temperature,pen = pen, symbol ='+',symbolSize =30,symbolBrush='r')

        df1  = pd.read_csv('Plot12.csv')
        x = df1['Date']
        x = pd.to_datetime(df1['Date'],infer_datetime_format=True)
        y = df1['AAPL.High']
        
        G3 = qtg.PlotWidget()
        G4 = qtg.PlotWidget()
        layoutC = QGridLayout()
        layoutC.addWidget(G1,0,0,1,1)
        layoutC.addWidget(G2,0,1,1,1)
        layoutC.addWidget(G3,1,1,1,1)
        layoutC.addWidget(G4,1,0,1,1)
        G3.plot(x,y, symbol ='+',symbolSize =30,symbolBrush='r')

        self.tab2.setLayout(layoutC)
       
        # Add tabs to widget
        self.layout.addWidget(self.tabs)
I Can easily create G2 chart, but not able to create G3 chart and error as below;
Quote:TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
there is no NAN or blank in my df
mine x dtype: datetime64[ns], y dtype: float64
this error came from x ?


RE: Line charts error "'isnan' not supported for the input types," - issac_n - Jul-22-2020

anyone help?