Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python - convert a column in a dataframe into a list

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

list to dataframe columns

import pandas as pd

lst = [1,2,3]
df = pd.DataFrame([lst])
df.columns =['col1','col2','col3']
df

to get this:

    col1    col2    col3
0   1       2       3
Comment

PREVIOUS NEXT
Code Example
Python :: python convert number to string with leading zeros 
Python :: discord.py ban 
Python :: tf 1 compatible colab 
Python :: how to check for a particular word in a text file using python 
Python :: matplotlib marker hollow circle 
Python :: pandas read_csv ignore unnamed columns 
Python :: webbrowser python could not locate runnable browser 
Python :: save file python tkinter 
Python :: pandas save without index 
Python :: alphabet list python 
Python :: tick labels vertical matplotlib 
Python :: pandas insert column in the beginning 
Python :: HOw to use passlock password manager python 
Python :: install mamba conda 
Python :: find the item with the maximum number of occurrences in a list in Python 
Python :: find table with class beautifulsoup 
Python :: how to clear a command line python 
Python :: check if string url python 
Python :: panda select rows where column value inferior to 
Python :: STandardScaler use example 
Python :: open url python 
Python :: infinity in python 
Python :: python access index in for loop 
Python :: how to import image in python 
Python :: python how to access clipboard 
Python :: python heart code 
Python :: install wxpython 
Python :: python jwt parse 
Python :: pd.set_option show all rows 
Python :: cors error in flask 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =