fork download
  1. import pandas as pd
  2.  
  3. df1 = pd.DataFrame(
  4. [
  5. [11, 12, 'Alice'],
  6. [21, 22, 'Bob']
  7. ],
  8. columns=['c1', 'c2', 'c3'],
  9. index=['i1', 'i2']
  10. )
  11.  
  12. df2 = pd.DataFrame(columns=df1.columns).astype(df1.dtypes)
  13. print(df2.shape)
  14. print(df2.dtypes)
Success #stdin #stdout 0.53s 60768KB
stdin
Standard input is empty
stdout
(0, 3)
c1     int64
c2     int64
c3    object
dtype: object