Python Practice › Pandas Programs › Program 57

Column values as a list

EasyPandas Programs · 57 of 95

Write a pandas program to get the values of a column as a list.

Advertisement
Output
['Alex', 'John', 'Peter']

Approach

  1. df["col"].tolist().

Solution

Python
import pandas as pddf = pd.DataFrame({"name": ["Alex", "John", "Peter"], "salary": [50000, 65000, 63000]})print(df["name"].tolist())
Output
['Alex', 'John', 'Peter']
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs