I've a DataFrame which contains the data for different students going to school. It has different columns like rank, major_code, major, unemployed etc.
I used df.values (in this case recent_grads.values) to Return a numpy representation of the DataFrame.
recent_grads_np = recent_grads.values
print(recent_grads_np)
This works as d.values changes the entire DataFrame into Numpy array. The result is this:
[[1 2419 'PETROLEUM ENGINEERING' ... 1534 364 193]
[2 2416 'MINING AND MINERAL ENGINEERING' ... 350 257 50]
[3 2415 'METALLURGICAL ENGINEERING' ... 456 176 0]
...
[172 5203 'COUNSELING PSYCHOLOGY' ... 2403 1245 308]
[173 3501 'LIBRARY SCIENCE' ... 288 338 192]]
How do I select only a few columns from the entire Dataframe and then convert into a numpy array ?