Highlight the nan values in Pandas Dataframe Last Updated : 26 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will discuss how to highlight the NaN (Not a number) values in Pandas Dataframe. NaN values used to represent NULL values and sometimes it is the result of the mathematical overflow.Lets first make a dataframe: Python3 # Import Required Libraries import pandas as pd import numpy as np # Create a dictionary for the dataframe dict = {'Name': ['Sumit Tyagi', 'Sukritin', 'Akriti Goel', 'Sanskriti', 'Abhishek Jain'], 'Age': [22, 20, np.nan, np.nan, 22], 'Marks': [90, 84, 33, 87, 82]} # Converting Dictionary to Pandas Dataframe df = pd.DataFrame(dict) # Print Dataframe df Output: Now, come to the highlighting part. Our objective is to highlight those cells which have Nan values. Method 1: Highlighting Cell with nan values We can do this by using the highlight_null() method of DataFrame.style property.This is a property that returns a Styler object, which has useful methods for formatting and displaying DataFrames. highlight_null() method requires one string parameter (the name of the colour with which you want to highlight the cell). Example: Python3 # Highlighting cell with nan values df.style.highlight_null('red') Output: Method 2: Highlighting text with nan values instead of background We can do this by using applymap() method of the style property. applymap() method requires a function that takes a scalar and returns a scalar.Example: Python3 # Highlighting text instead of the # cell's background df.style.applymap(lambda cell: 'color:red' if pd.isnull(cell) else '') Output: Method 3: Highlighting the text of the complete row with nan values We can do this using the apply() method Example: Python3 # Highlighting text of the complete row df.style.apply(lambda row: np.repeat('color: red' if row.isnull().any() else '', row.shape[0]), axis=1) Output: Method 4: Highlighting the complete row with nan values Python3 # Highlighting the complete row df.style.apply(lambda row: np.repeat('background: red' if row.isnull().any() else '', row.shape[0]), axis=1) Output: Solution 5: Highlighting the whole column with nan values Python3 # Highlighting column with nan values df.style.apply(lambda row: np.repeat('background: red' if row.isnull().any() else '', row.shape[0]), axis=0) Output: Comment More infoAdvertise with us Next Article Highlight the nan values in Pandas Dataframe S sumit_tyagi Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame pandas-dataframe-program Practice Tags : python Similar Reads Highlight the minimum value in each column In Pandas In this article, we will discuss how to Highlight the minimum values in Pandas Dataframe. So, Let's first make a dataframe: Python3 # Import Required Libraries import pandas as pd import numpy as np # Create a dictionary for the dataframe dict = { 'Name': ['Sumit Tyagi', 'Sukritin', 'Akriti Goel', ' 3 min read Highlight the maximum value in each column in Pandas Let's discuss how to highlight the maximum values in Pandas Dataframe. Lets first make a dataframe: Example: Python3 # Import Required Libraries import pandas as pd import numpy as np # Create a dictionary for the dataframe dict = {'Name': ['Sukritin', 'Sumit Tyagi', 'Akriti Goel', 'Sanskriti', 'Abh 2 min read How to Drop Negative Values in Pandas DataFrame Handling data effectively is crucial in data analysis and manipulation. One common task is cleaning the data by removing negative values, especially when they are considered outliers or invalid entries. The Pandas library in Python offers several efficient methods to accomplish this. This article wi 3 min read Ways to Create NaN Values in Pandas DataFrame Let's discuss ways of creating NaN values in the Pandas Dataframe. There are various ways to create NaN values in Pandas dataFrame. Those are: Using NumPy Importing csv file having blank values Applying to_numeric function Method 1: Using NumPy Python3 import pandas as pd import numpy as np num = {' 1 min read How to Drop Rows with NaN Values in Pandas DataFrame? In Pandas missing values are represented as NaN (Not a Number) which can lead to inaccurate analyses. One common approach to handling missing data is to drop rows containing NaN values using pandas. Below are some methods that can be used:Method 1: Using dropna()The dropna() method is the most strai 2 min read Like