Filling using index labels

Data can be filled using the labels of a Series or keys of a Python dictionary. This allows you to specify different fill values for different elements, based upon the value of the index label:

Only values of NaN are filled. Note that the values with label a are not changed.

Another common scenario is to fill all the NaN values in a column with the mean of the column:

This is convenient, as missing values replaced in this manner skew the statistical average less than if 0's are inserted. In certain statistical analyses, this may be acceptable where the larger deviation using 0 values can cause false failures.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset