Python Script for Pulling in the Same Column from an Array of Arrays

Imagine that we have a CSV file:

42,120000,Masters,Single,purchased
23,32000,High School,Single,no_purchase
,142000,Bachelors,Single,purchased
29,19000,PhD,Married,purchased
,21000,High School,Single,purchased
62,85000,High School,Married,no_purchase
70,,Bachelors,Married,purchased
,0,High School,Married,purchased
54,35000,High School,Married,no_purchase
16,16000,Masters,Single,no_purchase

 

That get converted into a Python collection, where each line in the CSV file represents an element from the list. If you want to return all of the education levels from the collection, you can run the script (for the example we're storing the collection in a variable called features):

features[1, 2]

 

This code will query the nested collections and return a single element from each collection, at the index of 2, the the output will be:

array([['Masters'],
       ['High School'],
       ['Bachelors'],
       ['PhD'],
       ['High School'],
       ['High School'],
       ['Bachelors'],
       ['High School'],
       ['High School'],
       ['Masters']], dtype=object)