Guest User

Untitled

a guest
Aug 18th, 2019
88
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 6,
  6. "metadata": {},
  7. "outputs": [
  8. {
  9. "data": {
  10. "text/html": [
  11. "<div>\n",
  12. "<style scoped>\n",
  13. " .dataframe tbody tr th:only-of-type {\n",
  14. " vertical-align: middle;\n",
  15. " }\n",
  16. "\n",
  17. " .dataframe tbody tr th {\n",
  18. " vertical-align: top;\n",
  19. " }\n",
  20. "\n",
  21. " .dataframe thead th {\n",
  22. " text-align: right;\n",
  23. " }\n",
  24. "</style>\n",
  25. "<table border=\"1\" class=\"dataframe\">\n",
  26. " <thead>\n",
  27. " <tr style=\"text-align: right;\">\n",
  28. " <th></th>\n",
  29. " <th>User ID</th>\n",
  30. " <th>Gender</th>\n",
  31. " <th>Age</th>\n",
  32. " <th>EstimatedSalary</th>\n",
  33. " <th>Purchased</th>\n",
  34. " </tr>\n",
  35. " </thead>\n",
  36. " <tbody>\n",
  37. " <tr>\n",
  38. " <th>0</th>\n",
  39. " <td>15624510</td>\n",
  40. " <td>1</td>\n",
  41. " <td>19</td>\n",
  42. " <td>19000</td>\n",
  43. " <td>0</td>\n",
  44. " </tr>\n",
  45. " <tr>\n",
  46. " <th>1</th>\n",
  47. " <td>15810944</td>\n",
  48. " <td>1</td>\n",
  49. " <td>35</td>\n",
  50. " <td>20000</td>\n",
  51. " <td>0</td>\n",
  52. " </tr>\n",
  53. " <tr>\n",
  54. " <th>2</th>\n",
  55. " <td>15668575</td>\n",
  56. " <td>0</td>\n",
  57. " <td>26</td>\n",
  58. " <td>43000</td>\n",
  59. " <td>0</td>\n",
  60. " </tr>\n",
  61. " <tr>\n",
  62. " <th>3</th>\n",
  63. " <td>15603246</td>\n",
  64. " <td>0</td>\n",
  65. " <td>27</td>\n",
  66. " <td>57000</td>\n",
  67. " <td>0</td>\n",
  68. " </tr>\n",
  69. " <tr>\n",
  70. " <th>4</th>\n",
  71. " <td>15804002</td>\n",
  72. " <td>1</td>\n",
  73. " <td>19</td>\n",
  74. " <td>76000</td>\n",
  75. " <td>0</td>\n",
  76. " </tr>\n",
  77. " </tbody>\n",
  78. "</table>\n",
  79. "</div>"
  80. ],
  81. "text/plain": [
  82. " User ID Gender Age EstimatedSalary Purchased\n",
  83. "0 15624510 1 19 19000 0\n",
  84. "1 15810944 1 35 20000 0\n",
  85. "2 15668575 0 26 43000 0\n",
  86. "3 15603246 0 27 57000 0\n",
  87. "4 15804002 1 19 76000 0"
  88. ]
  89. },
  90. "execution_count": 6,
  91. "metadata": {},
  92. "output_type": "execute_result"
  93. }
  94. ],
  95. "source": [
  96. "df.head()"
  97. ]
  98. },
  99. {
  100. "cell_type": "code",
  101. "execution_count": 5,
  102. "metadata": {},
  103. "outputs": [
  104. {
  105. "data": {
  106. "text/html": [
  107. "<div>\n",
  108. "<style scoped>\n",
  109. " .dataframe tbody tr th:only-of-type {\n",
  110. " vertical-align: middle;\n",
  111. " }\n",
  112. "\n",
  113. " .dataframe tbody tr th {\n",
  114. " vertical-align: top;\n",
  115. " }\n",
  116. "\n",
  117. " .dataframe thead th {\n",
  118. " text-align: right;\n",
  119. " }\n",
  120. "</style>\n",
  121. "<table border=\"1\" class=\"dataframe\">\n",
  122. " <thead>\n",
  123. " <tr style=\"text-align: right;\">\n",
  124. " <th></th>\n",
  125. " <th>User ID</th>\n",
  126. " <th>Gender</th>\n",
  127. " <th>Age</th>\n",
  128. " <th>EstimatedSalary</th>\n",
  129. " <th>Purchased</th>\n",
  130. " </tr>\n",
  131. " </thead>\n",
  132. " <tbody>\n",
  133. " <tr>\n",
  134. " <th>0</th>\n",
  135. " <td>15624510</td>\n",
  136. " <td>1</td>\n",
  137. " <td>19</td>\n",
  138. " <td>19000</td>\n",
  139. " <td>0</td>\n",
  140. " </tr>\n",
  141. " <tr>\n",
  142. " <th>1</th>\n",
  143. " <td>15810944</td>\n",
  144. " <td>1</td>\n",
  145. " <td>35</td>\n",
  146. " <td>20000</td>\n",
  147. " <td>0</td>\n",
  148. " </tr>\n",
  149. " </tbody>\n",
  150. "</table>\n",
  151. "</div>"
  152. ],
  153. "text/plain": [
  154. " User ID Gender Age EstimatedSalary Purchased\n",
  155. "0 15624510 1 19 19000 0\n",
  156. "1 15810944 1 35 20000 0"
  157. ]
  158. },
  159. "execution_count": 5,
  160. "metadata": {},
  161. "output_type": "execute_result"
  162. }
  163. ],
  164. "source": [
  165. "df.replace({'Male':1,'Female':0},inplace=True)\n",
  166. "df.head(2)"
  167. ]
  168. },
  169. {
  170. "cell_type": "code",
  171. "execution_count": null,
  172. "metadata": {},
  173. "outputs": [],
  174. "source": []
  175. }
  176. ],
  177. "metadata": {
  178. "kernelspec": {
  179. "display_name": "Python 3",
  180. "language": "python",
  181. "name": "python3"
  182. },
  183. "language_info": {
  184. "codemirror_mode": {
  185. "name": "ipython",
  186. "version": 3
  187. },
  188. "file_extension": ".py",
  189. "mimetype": "text/x-python",
  190. "name": "python",
  191. "nbconvert_exporter": "python",
  192. "pygments_lexer": "ipython3",
  193. "version": "3.7.3"
  194. }
  195. },
  196. "nbformat": 4,
  197. "nbformat_minor": 2
  198. }
RAW Paste Data