Ways to Create NaN Values in Pandas DataFrame Last Updated : 08 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 = {'number': [1,2,np.nan,6,7,np.nan,np.nan]} df = pd.DataFrame(num) df Output: Method 2: Importing the CSV file having blank instances Consider the below csv file named "Book1.csv": Code: Python3 # import pandas import pandas as pd # read file df = pd.read_csv("Book1.csv") # print values df Output: You will get Nan values for blank instances. Method 3: Applying to_numeric function to_numeric function converts arguments to a numeric type. Example: Python3 import pandas as pd num = {'data': [1,"hjghjd",3,"jxsh"]} df = pd.DataFrame(num) # this will convert non-numeric # values into NaN values df = pd.to_numeric(df["data"], errors='coerce') df Output: Comment More infoAdvertise with us Next Article Ways to Create NaN Values in Pandas DataFrame R romy421kumari Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Practice Tags : python Similar Reads Count Values in Pandas Dataframe Counting values in Pandas dataframe is important for understanding the distribution of data, checking for missing values or summarizing data. In this article, we will learn various methods to count values in a Pandas DataFrameWe will be using below dataframe to learn about various methods:Pythonimpo 3 min read How to Drop Columns with NaN Values in Pandas DataFrame? Nan(Not a number) is a floating-point value which can't be converted into other data type expect to float. In data analysis, Nan is the unnecessary value which must be removed in order to analyze the data set properly. In this article, we will discuss how to remove/drop columns having Nan values in 3 min read Replace NaN Values with Zeros in Pandas DataFrame NaN stands for Not A Number and is one of the common ways to represent the missing value in the data. It is a special floating-point value and cannot be converted to any other type than float. NaN value is one of the major problems in Data Analysis. It is very essential to deal with NaN in order to 5 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 Highlight the nan values in Pandas Dataframe 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 2 min read Like