title: Converting python datatype using astype leads to KeyError: error
body: <p>Hi I am trying to change a datatype but unsuccessful.
  Code Snippet:</p>
  <pre><code>for i in d:
      new_dtype = {d['column_name'] : d['cast_type']}
  
      for k, v in new_dtype.items():
          insert_df[tname][k] = insert_df[tname][k].astype[v]
  </code></pre>
  <pre><code>Error seen in the log:
  Traceback (most recent call last):
    File &quot;/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pandas/core/indexes/base.py&quot;, line 3621, in get_loc
      return self._engine.get_loc(casted_key)
    File &quot;pandas/_libs/index.pyx&quot;, line 136, in pandas._libs.index.IndexEngine.get_loc
    File &quot;pandas/_libs/index.pyx&quot;, line 163, in pandas._libs.index.IndexEngine.get_loc
    File &quot;pandas/_libs/hashtable_class_helper.pxi&quot;, line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
    File &quot;pandas/_libs/hashtable_class_helper.pxi&quot;, line 5206, in 
      pandas._libs.hashtable.PyObjectHashTable.get_item
      KeyError: 'selected'
  
    raise KeyError(key) from err
  KeyError: 'selected'
  </code></pre>
  <p>If I try to print the key and value from the dictionary, the key selected exist</p>
  <pre><code>selected int32
  selected int32
  selected int32
  positive int32
  positive int32
  positive int32
  </code></pre>
  <p>This is the value of d:                                              types_dict = df.to_dict(orient='records')</p>
  <pre><code>                type_conversion = {
                  &quot;bigint&quot;: &quot;int64&quot;,
                  &quot;boolean&quot;: &quot;bool&quot;,
                  &quot;character varying&quot;: &quot;str&quot;,
                  &quot;double precision&quot;: &quot;float64&quot;,
                  &quot;integer&quot;: &quot;int32&quot;,
                  &quot;numeric&quot;: &quot;float64&quot;,
                  &quot;timestamp without time zone&quot;: &quot;datetime64&quot; 
                  }
                  
                  for d in types_dict:
                      d['cast_type'] = type_conversion[d['col_type']]
  </code></pre>
  <p>Any hints/advice? Thanks!!</p>