Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment