Finding non-numeric rows in dataframe in pandas

Given a Pandas DataFrame, we have to find non-numeric rows.
Submitted by Pranit Sharma, on July 23, 2022

Pandas is a special tool that allows us to perform complex manipulations of data effectively and efficiently. Inside pandas, we mostly deal with a dataset in the form of DataFrame. DataFrames are 2-dimensional data structures in pandas. DataFrames consist of rows, columns, and data.

Sometimes, while dealing with a large data set, we deal with every kind of data type but we need some specific data types.

For instance, we sometimes need to find non-numeric rows in DataFrame, pandas allow us to achieve this task. For this purpose, we will first use the map() method which will help us to traverse each value of DataFrame so that we can check the value at the same time. We will check the value using np.isreal() method.

np.isreal() method returns Boolean value. If it returns True, it means that the value is numeric and if False is the result, then the value is non-numeric.

In this way, we can check that a row is numeric or non-numeric values in it.

Let us understand with the help of an example,

Python code to find non-numeric rows in dataframe in pandas

# Importing pandas package
import pandas as pd

# Importing numpy package
import numpy as np

# Creating a Dictionary
d = {

# Creating a DataFrame
df = pd.DataFrame(d)

# Display original DataFrame
print("Original DataFrame:\n",df,"\n")

# Checking values
result = df.applymap(np.isreal)

# Display result


Example: Finding non-numeric rows

Python Pandas Programs »


Comments and Discussions!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.