Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. df = pd.DataFrame({'A': 'foo bar foo bar foo bar foo foo'.split(),
  4. 'B': 'one one two three two two one three'.split(),
  5. 'C': np.arange(8), 'D': np.arange(8) * 2})
  6. print(df)
  7. # A B C D
  8. # 0 foo one 0 0
  9. # 1 bar one 1 2
  10. # 2 foo two 2 4
  11. # 3 bar three 3 6
  12. # 4 foo two 4 8
  13. # 5 bar two 5 10
  14. # 6 foos one 6 12
  15. # 7 foo three 7 14
  16.  
  17. print(df.loc[df['A'] == 'foo'])
  18.  
  19. A B C D
  20. 0 foo one 0 0
  21. 2 foo two 2 4
  22. 4 foo two 4 8
  23. 7 foo three 7 14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement