Advertisement
ivana_andreevska

pd.DataFrame

Oct 25th, 2022 (edited)
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. import pandas as pd
  2. data={
  3.     "calories":[420,380,390],
  4.     "duration":[50,40,45]
  5. }
  6. df=pd.DataFrame(data)
  7. print(df)
  8.  
  9. print('\n')
  10.  
  11. #refer to the row index
  12. print(df.loc[0])
  13. print('\n')
  14. #return row 0 and 1
  15. print(df.loc[[0,1]])
  16.  
  17. print('\n')
  18.  
  19. df=pd.DataFrame(data,index=["day1","day2","day3"])
  20. print(df)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement