🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 106 (from laksa170)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
13 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.5 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.includehelp.com/python/pandas-how-to-remove-nan-and-inf-values.aspx
Last Crawled2026-03-27 04:53:06 (13 days ago)
First Indexed2023-02-13 12:55:54 (3 years ago)
HTTP Status Code200
Meta TitlePython - Pandas: How to remove nan and -inf values?
Meta DescriptionIn this tutorial, we are going to learn how to remove nan and -inf values in Python Pandas?
Meta Canonicalnull
Boilerpipe Text
Home » Python » Python Programs Learn, how to remove nan and -inf values in Python Pandas? By Pranit Sharma Last updated : October 06, 2023 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. Problem statement Suppose that we are given a dataframe that contains several rows and columns with nan and -inf values too. We need to remove these nans and -inf values for better data analysis. Removing nan and -inf values For this purpose, we will use pandas.DataFrame.isin() and check for rows that have any with pandas.DataFrame.any() . Finally, we will use the boolean array to slice the dataframe. Let us understand with the help of an example, Python program to remove nan and -inf values from pandas dataframe # Importing pandas package import pandas as pd # Import numpy import numpy as np from numpy import inf # Creating a dataframe df = pd . DataFrame(data = { 'X' : [ 1 , 1 ,np . nan], 'Y' : [ 8 , - inf, 7 ], 'Z' : [ 5 , - inf, 4 ], 'A' : [ 3 ,np . nan, 7 ]}) # Display the DataFrame print ( "Original DataFrame: \n " ,df, " \n\n " ) # Removing nan and -inf res = df[ ~ df . isin([np . nan, - np . inf]) . any( 1 )] # Display Result print ( "Result: \n " ,res) Output The output of the above program is: Python Pandas Programs » Advertisement Advertisement
Markdownnull
Readable Markdown
[Home](https://www.includehelp.com/default.aspx) » [Python](https://www.includehelp.com/python/default.aspx) » [Python Programs](https://www.includehelp.com/python/programs.aspx) Learn, how to remove nan and -inf values in Python Pandas? By [Pranit Sharma](https://www.includehelp.com/Members/Pranit-Sharma.aspx) Last updated : October 06, 2023 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](https://www.includehelp.com/python/pandas-dataframe-in-python.aspx) are 2-dimensional data structures in pandas. DataFrames consist of rows, columns, and data. ## Problem statement Suppose that we are given a dataframe that contains several rows and columns with *nan* and *\-inf* values too. We need to remove these *nans* and *\-inf* values for better data analysis. ## Removing nan and -inf values For this purpose, we will use pandas.DataFrame.isin() and check for rows that have any with pandas.DataFrame.any(). Finally, we will use the boolean array to slice the dataframe. Let us understand with the help of an example, ## Python program to remove nan and -inf values from pandas dataframe ``` # Importing pandas package import pandas as pd # Import numpy import numpy as np from numpy import inf # Creating a dataframe df = pd.DataFrame(data={'X': [1,1,np.nan], 'Y': [8,-inf,7], 'Z': [5,-inf,4],'A': [3,np.nan,7]}) # Display the DataFrame print("Original DataFrame:\n",df,"\n\n") # Removing nan and -inf res = df[~df.isin([np.nan, -np.inf]).any(1)] # Display Result print("Result:\n",res) ``` ### Output The output of the above program is: ![Example: Pandas: How to remove nan and -inf values?](https://www.includehelp.com/python/images/remove-nan-and-inf-values.jpg) [Python Pandas Programs »](https://www.includehelp.com/python/pandas-programs.aspx) Advertisement Advertisement
Shard106 (laksa)
Root Hash1184066710662109106
Unparsed URLcom,includehelp!www,/python/pandas-how-to-remove-nan-and-inf-values.aspx s443