Guest User

Untitled

a guest
Apr 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import pandas as pd
  2.  
  3. bad_px = ["12", "34"]
  4.  
  5. df = pd.DataFrame({
  6. "px_id": [1, 2, 3],
  7. "px": ["12", "34", "56"],
  8. "px_type": ["10", "10", "09"]
  9. })
  10.  
  11. print("Original: \n{}".format(df))
  12. index = df["px"].isin(bad_px)
  13. df.ix[index, "px_type"] = '09'
  14. print("Fixed: \n {} ".format(df))
  15.  
  16. # Original:
  17. # px px_id px_type
  18. # 0 12 1 10
  19. # 1 34 2 10
  20. # 2 56 3 09
  21. # Fixed:
  22. # px px_id px_type
  23. # 0 12 1 09
  24. # 1 34 2 09
  25. # 2 56 3 09
Add Comment
Please, Sign In to add comment