I have the following dataframe.
my_list= [(343, 4364), (221, 791), (221, 2847), (21, 1296)]
from this list I would like to pick the second value from the list values and get the following list.
new_list = [4364, 791, 2847, 1296]
Can any one help on this?
>Solution :
What you are describing are just lists not pandas DataFrames. In order to get the second element, the easiest solution is probably to use list comprehension:
my_list= [(343, 4364), (221, 791), (221, 2847), (21, 1296)]
new_list = [x for _, x in my_list]
# or
new_list = [x[1] for x in my_list]
If you are indeed working with pandas, you can use [] to get desired column:
df = pandas.DataFrame([(343, 4364), (221, 791), (221, 2847), (21, 1296)])
col = df[1]