Python Forum

Full Version: Line charts error "'isnan' not supported for the input types,"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
anyone help?