Last active
December 13, 2017 08:35
-
-
Save ruoyu0088/4e775bf2b157fb14d547e3b1e4a24a22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import io | |
data = """ name, type, number | |
0, David, A, 1234 | |
1, Tom, B, 2233 | |
2, Jack, C, 2244 | |
3, Allen, B, 2355 | |
4, , D, 2345 | |
5, Test, E, 3456 | |
6, Test, A, 111 | |
""" | |
df = pd.read_csv(io.StringIO(data), skipinitialspace=True) | |
df.name.fillna("", inplace=True) | |
types = ['A', 'B', 'C', 'D'] | |
df.eval("is_valid = name != '' & type in @types & number >= 1000 & number <= 9999", inplace=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment