daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Feb 14th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. d = {'col1': [1,"newcolumn1name",5, 8,15 ], 'col2':[5,"newcolumn2name"10,15, 20]}
  3. df = pd.DataFrame(data=d)
  4. df1=df
  5. df2=df
  6.  
  7. df
  8. Out[24]:
  9.              col1            col2
  10. 0               1               5
  11. 1  newcolumn1name  newcolumn2name
  12. 2               5              10
  13. 3               8              15
  14. 4              15              20
  15.    
  16. df=df[1:]
  17. new_header = df.iloc[0]
  18. df=df[1:]
  19. df.columns = new_header
  20.  
  21. df
  22. Out[26]:
  23. 1 newcolumn1name newcolumn2name
  24. 2              5             10
  25. 3              8             15
  26. 4             15             20
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top