0

I am new in Oracle and Python and I connected my python to Oracle. I had this table on my Oracle database and I wanted to write a simple query to see my result but it gave me this error:

Input contains NaN, infinity or a value too large for dtype('float64').

My code:

SQL_Query2 = pd.read_sql_query('''select Province_name, cnt from Provincepartnercnt''' , conn)
x_test = pd.DataFrame(SQL_Query2, columns=['Province_name','cnt'])
SQL_Query = pd.read_sql_query('''select Province_name, cnt from Provincepartnercnt''' , conn)
x_train = pd.DataFrame(SQL_Query, columns=['Province_name','cnt'])
myKNN = KNeighborsClassifier(n_neighbors = 1)
myKNN.fit(x_test, x_train)

Also my datatype are not float: one of my columns is in VARCHAR2(150 BYTE) and the other one is in NUMBER(38,0). Also I have to mention that non of my rows are null or anything else.

Christopher Jones
  • 9,449
  • 3
  • 24
  • 48
Sara Moradi
  • 35
  • 1
  • 7
  • Does this answer your question? [sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype('float64')](https://stackoverflow.com/questions/31323499/sklearn-error-valueerror-input-contains-nan-infinity-or-a-value-too-large-for) or [ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). sklearn](https://stackoverflow.com/q/62702691) – astentx Sep 20 '21 at 07:43
  • Where does `KNeighborsClassifier` come from? – astentx Sep 20 '21 at 08:58
  • The most probable explanation is that you try to convert the `Province_name` to `float` which leads to `NaN`. Also *suspitious* is that you pass to `fit` two *identical* parameters (created by the same query). You should re-think what are your *features* and *target* – Marmite Bomber Sep 20 '21 at 16:23

1 Answers1

0

I found a way to insert my data without using that query. Maybe the problem is using sklearn. ( I just simply use this code.)

My code:

cursor = conn.cursor()
query= cursor.execute("select ostan_name, cnt from ostanpartnercnt")

for row in re:
    print(row)
Sara Moradi
  • 35
  • 1
  • 7