How to print pandas column values, names and types?

Print pandas columns

You can export your one or multiple pandas DataFrame column values into a string or list object and print those in your Jupyter Notebook using the following syntax:


# alternatively


Step 1: Create example data

Let’s start by creating some test data that you can use to follow along:

import pandas as pd

month = ['July', 'September', 'November', 'September', 'December']
language = ['Java', 'Java', 'R', 'Javascript', 'R']
salary = [114.0, 166.0, 155.0, 158.0, 131.0]
data = dict(month = month, language = language, salary = salary)
hiring_data = pd.DataFrame(data=data)

Step 2: Get and export column values

You can easily export the values of your month column by slicing a Series object and converting it to a string:


This will return the following string:

0         July
1    September
2     November
3    September
4     December

Step 3: Print column values not index

As you see, the row indices were exported as well. You can get rid of the index when printing by using the following syntax which prints a Numpy array containing the column values:


This returns the following ndarray:

['July' 'September' 'November' 'September' 'December']

Another way to export just the column values is using the index=False parameter of the to_string() function:


You can also print the values directly to a Python list using this code:


Step 4: Export DataFrame column names

You can print your DataFrame column names using the following snippet:


This returns an ndarray that contains the DataFRame column names:

['month' 'language' 'salary']

Step 5: Print pandas column types

In a similar fashion you can get the column data types (dypes of each of your DataFrame columns):


This returns the following content:

month        object
language     object
salary      float64

Step 6: Print specific columns with condition

Next we would like to print only values in a column which meet a condition. For example, all relevant values ending with the string ‘ber’. We’ll first slice the Series and then convert it to a string for easier printing.

cond = hiring_data['month'].str.endswith('ber')
print(hiring_data['month'] [cond].to_string())