'How to fix the datatype mismatch when loading data from database

I'm loading data from mongoDB and Oracle Database and converting them to dataframe. but the problem is when I check the datatype of each column, it is panda series <panda.core.series.Series>. is there any way I could retain the original datatype of each column

oracle:

read_query="select * from Table1"
df1=pd.DataFrame(pd.read_sql(read_query,conn)

Mongo:

client = MongoClient(mongo_conn)
mydb= client[mongo_schema]
mycol = mydb['tab']

read_query = {'value_id':{ '$in':[i for i in ids]}}
read_proj = { '_id':0,
              'name':'$name',
              'age':'$age',
              'Dob':'$dob',
               ....}
mongo_list=mycol.find(read_query,read_proj)
df2 = pd.DataFrame(list(mongo_list))

print(type(df1['col1'])
print(type(df2['age'])

<panda.core.series.Series>
<panda.core.series.Series>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source