Missing data types
While working with real-world datasets, you are bound to encounter missing data quite frequently during data analysis. Understanding how pandas displays missing data for each dtype is crucial to ensure that your data analysis is correct.
The missing alphabet soup
In the previous section, we learned about the different data types and how to convert them if needed. Here, we will learn about how to represent missing data for each data type.
We will continue with our previous example. However, this time, we will replace some values with None
, as follows:
data_frame.drop(['year','month','day'], axis = 1, inplace=True) data_frame.iloc[0,0] = None data_frame.iloc[4,1] = None data_frame.iloc[2,2] = None data_frame.iloc[3,3] = None data_frame.iloc[3,4] = None data_frame.iloc[1,5] = None data_frame.iloc[2,6] = None data_frame
Upon running this snippet, you should see the following output: