Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 12:22:00)
- [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import numpy as np
- >>> import pandas as pd
- >>> test = pd.DataFrame(np.random.choice([0.0, 100.0], size=(4, 4)))
- >>> test
- 0 1 2 3
- 0 0.0 0.0 100.0 100.0
- 1 100.0 100.0 0.0 100.0
- 2 0.0 100.0 100.0 100.0
- 3 100.0 100.0 100.0 100.0
- >>> train = pd.DataFrame(np.random.rand(4, 4))
- >>> train
- 0 1 2 3
- 0 0.435729 0.543282 0.911146 0.394409
- 1 0.693686 0.955173 0.729586 0.808441
- 2 0.155083 0.327989 0.405951 0.854187
- 3 0.623706 0.349019 0.286164 0.626817
- >>> test = test.where(test == 0, train)
- >>> test
- 0 1 2 3
- 0 0.000000 0.000000 0.911146 0.394409
- 1 0.693686 0.955173 0.000000 0.808441
- 2 0.000000 0.327989 0.405951 0.854187
- 3 0.623706 0.349019 0.286164 0.626817
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement