SHARE
TWEET

Untitled

a guest Jun 18th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. import numpy as np
  3.  
  4. df = pd.DataFrame({'value': np.random.randint(0, 100, 20)})
  5. labels = ["{0} - {1}".format(i, i + 9) for i in range(0, 100, 10)]
  6. df['range'] = pd.cut(df.value, range(0, 105, 10), right=False, labels=labels)
  7. df['relation'] = pd.DataFrame({'value': np.random.randint(0, 100, 20)})
  8. df['answer'] = np.tile(['good', 'bad', 'average'], df.index.size)[:df.index.size]
  9. df['answer'] = df['answer'].astype('category')
  10.      
  11. In [2]: df.head(10)
  12. Out[2]:
  13.    value    range  relation   answer
  14. 0     16  10 - 19        19     good
  15. 1     52  50 - 59        61      bad
  16. 2     19  10 - 19        83  average
  17. 3     23  20 - 29        43     good
  18. 4     18  10 - 19        44      bad
  19. 5     41  40 - 49        86  average
  20. 6     52  50 - 59        40     good
  21. 7     78  70 - 79        74      bad
  22. 8     30  30 - 39        82  average
  23. 9     63  60 - 69        27     good
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top