Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- df = pd.DataFrame({'A': 'foo bar foo bar foo bar foo foo'.split(),
- 'B': 'one one two three two two one three'.split(),
- 'C': np.arange(8), 'D': np.arange(8) * 2})
- print(df)
- # A B C D
- # 0 foo one 0 0
- # 1 bar one 1 2
- # 2 foo two 2 4
- # 3 bar three 3 6
- # 4 foo two 4 8
- # 5 bar two 5 10
- # 6 foos one 6 12
- # 7 foo three 7 14
- print(df.loc[df['A'] == 'foo'])
- A B C D
- 0 foo one 0 0
- 2 foo two 2 4
- 4 foo two 4 8
- 7 foo three 7 14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement