pandas_cocantenating_appending.py 795 B

1234567891011121314151617181920212223242526272829
  1. import pandas as pd
  2. df1 = pd.DataFrame({'HPI':[80,85,88,85],
  3. 'Int_rate':[2, 3, 2, 2],
  4. 'US_GDP_Thousands':[50, 55, 65, 55]},
  5. index = [2001, 2002, 2003, 2004])
  6. df2 = pd.DataFrame({'HPI':[80,85,88,85],
  7. 'Int_rate':[2, 3, 2, 2],
  8. 'US_GDP_Thousands':[50, 55, 65, 55]},
  9. index = [2005, 2006, 2007, 2008])
  10. df3 = pd.DataFrame({'HPI':[80,85,88,85],
  11. 'Int_rate':[2, 3, 2, 2],
  12. 'Low_tier_HPI':[50, 52, 50, 53]},
  13. index = [2001, 2002, 2003, 2004])
  14. # df1.set_index('HPI', inplace=True)
  15. concat = pd.concat([df1, df3])
  16. df4 = df1.append(df3)
  17. print(concat)
  18. print(df4)
  19. s = pd.Series([[80, 2, 50],[80, 54, 56], [56, 43, 23]])
  20. print(s)