python - convert a column in a dataframe into a list 1

python – convert a column in a dataframe into a list

myvar_list = df["myvar"].tolist()

Here is what the above code is Doing:
1. We’re creating a list of the values in the “myvar” column.
2. We’re assigning that list to the variable “myvar_list”.

You can now use the “myvar_list” variable in your code.

Similar Posts