Created
April 13, 2018 14:05
-
-
Save indera/0478be912adce630df2c3782425db03f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
bad_px = ["12", "34"] | |
df = pd.DataFrame({ | |
"px_id": [1, 2, 3], | |
"px": ["12", "34", "56"], | |
"px_type": ["10", "10", "09"] | |
}) | |
print("Original: \n{}".format(df)) | |
index = df["px"].isin(bad_px) | |
df.ix[index, "px_type"] = '09' | |
print("Fixed: \n {} ".format(df)) | |
# Original: | |
# px px_id px_type | |
# 0 12 1 10 | |
# 1 34 2 10 | |
# 2 56 3 09 | |
# Fixed: | |
# px px_id px_type | |
# 0 12 1 09 | |
# 1 34 2 09 | |
# 2 56 3 09 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment