title: How to convert np.int64 into python int64 for PandasSeries?
body: <p>I try to insert data from pandas DataFrame into the PostgreSQL table, </p>
  
  <p>table that a try to insert looks like:</p>
  
  <pre><code>city_id date        forecast
  5       29.05.2019  0
  1       29.05.2019  0
  151     29.05.2019  0
  55      29.05.2019  0
  ...
  </code></pre>
  
  <p><strong>types:</strong></p>
  
  <ul>
  <li><code>city_id</code> - <code>numpy.int64</code></li>
  <li><code>date</code> - <code>datetime.date</code></li>
  <li><code>forecast</code> - <code>numpy.int64</code></li>
  </ul>
  
  <p>And the <strong>block of code</strong>, that inserting data to db:</p>
  
  <pre><code>        with psycopg2.connect(f"host='{hostname}' \
                                dbname='{database}' \
                                user='{username}' \
                                password='{password}'") as connection:
              with connection.cursor() as cursor:
                  connection.set_client_encoding('UTF8')
                  for i in df_with_new_one.index:
                      date = df_with_new_one['date'][i]
                      city_id = df_with_new_one['city_id'][i]
                      value = df_with_new_one['forecast'][i]
  
                      cursor.execute("INSERT INTO forecast \
                      (city_id, computed_time, date, value) \
                      VALUES (%s, %s, %s, %s)", (city_id, now, date, value)) 
  </code></pre>
  
  <p>Where <code>now</code> is time saved as <code>datetime.datetime.now()</code></p>
  
  <p><strong>And i get</strong> <em>ProgrammingError</em>:</p>
  
  <pre><code>    ProgrammingError: can't adapt type 'numpy.int64'
  </code></pre>
  
  <p>I checked <strong>type</strong> <code>type(df_with_new_one['forecast'][0])</code> type is <code>numpy.int64</code></p>
  
  <p>So I get that PostreSQL can read only pythonic <code>int</code> and <code>float</code>, and the first thing i've tried was converting <code>np.int64</code> into simple <code>int</code> with:</p>
  
  <ul>
  <li><code>tolist()</code> </li>
  <li><code>pd.to_numeric()</code></li>
  <li><code>int()</code> for <code>((int(city_id), now, date, int(value))</code></li>
  <li><code>.astype(int)</code></li>
  <li><code>.value.astype('int')</code></li>
  </ul>
  
  <p><strong>Upd.:</strong></p>
  
  <ul>
  <li><code>city_id = int(df_with_new_one['city_id'][i])</code>
  <code>value = int(df_with_new_one['forecast'][i])</code></li>
  </ul>
  
  <p>Unfortunately <strong>none of them works</strong> for me</p>
  
  <p>When I tried <code>int()</code> I get another error: </p>
  
  <pre><code>    TypeError: cannot convert the series to &lt;class 'int'&gt;
  </code></pre>
  
  <p>Answers that <strong>i found</strong>, but no one of them helped me:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/50626058/psycopg2-cant-adapt-type-numpy-int64">psycopg2: can&#39;t adapt type &#39;numpy.int64&#39;</a></li>
  <li><a href="https://stackoverflow.com/questions/39564755/programmingerror-psycopg2-programmingerror-cant-adapt-type-numpy-ndarray">ProgrammingError: (psycopg2.ProgrammingError) can&#39;t adapt type &#39;numpy.ndarray&#39;</a></li>
  <li><a href="https://stackoverflow.com/questions/41000428/python-typeerror-cannot-convert-the-series-to-class-int-when-trying-to-do-m">Python TypeError: cannot convert the series to &lt;class &#39;int&#39;&gt; when trying to do math on dataframe</a></li>
  <li><a href="https://stackoverflow.com/questions/48120611/python-pandas-filtering-typeerror-cannot-convert-the-series-to-class-int?rq=1">Python Pandas filtering; TypeError: cannot convert the series to &lt;class &#39;int&#39;&gt;</a></li>
  </ul>
  
  <p>Are there <strong>any other methods</strong> to change type of values?</p>