Having consistent schemas between two Pandas DataFrames is essential when saving to Parquet and for merging operations.
Simply run a comparison operator after applying dtypes
to both DataFrames:
df1 = pd.DataFrame([[1,2,3],[1,2,3],[1,2,3]],columns=['A','B','C']) df2 = pd.DataFrame([[1,2,'a'],[1,2,'b'],[1,2,'c']],columns=['A','B','C']) df1.dtypes == df2.dtypes
The result printed to the console will be True
or False
depending on whether or not the data types are the same.
Final Thoughts
Check out more Python tricks in this Colab Notebook or in my recent Python Posts.
Thanks for reading!