Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 12:22:00)
  2. [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> import numpy as np
  5. >>> import pandas as pd
  6. >>> test = pd.DataFrame(np.random.choice([0.0, 100.0], size=(4, 4)))
  7. >>> test
  8. 0 1 2 3
  9. 0 0.0 0.0 100.0 100.0
  10. 1 100.0 100.0 0.0 100.0
  11. 2 0.0 100.0 100.0 100.0
  12. 3 100.0 100.0 100.0 100.0
  13. >>> train = pd.DataFrame(np.random.rand(4, 4))
  14. >>> train
  15. 0 1 2 3
  16. 0 0.435729 0.543282 0.911146 0.394409
  17. 1 0.693686 0.955173 0.729586 0.808441
  18. 2 0.155083 0.327989 0.405951 0.854187
  19. 3 0.623706 0.349019 0.286164 0.626817
  20. >>> test = test.where(test == 0, train)
  21. >>> test
  22. 0 1 2 3
  23. 0 0.000000 0.000000 0.911146 0.394409
  24. 1 0.693686 0.955173 0.000000 0.808441
  25. 2 0.000000 0.327989 0.405951 0.854187
  26. 3 0.623706 0.349019 0.286164 0.626817
  27. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement