Converting DataFrame columns to lists

To extract the contents of a column into a list, you can use the tolist() function. After being converted to a list, the data can then be iterated over using for loops and comprehensions:

my_list = df3['new_col3'].tolist()
print(my_list)

The output is as follows:

[5, 7, 9, 11, 13, 15, 17]

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset