I have a question regarding data types and creating a data frame through a read_sql method vs a read_csv method. Will the data types associated with the database/table be “brought over” when the data is read into a data frame, or are data types implicitly determined by pandas when the data is read in (like in read_csv)?
Databases have much more datatypes than pandas, and different databases have different types among each other too. Whatever database is used, it all has to become pandas datatypes eventually (the exact mapping i’m not sure). Both your statements are correct. They are brought over in the sense that a
NULL in postgres becomes a
nan in pandas after
timestamp in postgres becomes a
datetime64[ns] in pandas, so the distinction they have in the database gets transferred to the pandas space. But they are also determined by pandas because the names of the types (and probably storage efficiency too) have changed.
That makes sense. Thanks!