12.3.10.4.6. Missing data#

import pandas as pd
import numpy as np


dates = pd.date_range("20220501", periods=6)
dataFrame = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list("ABCD"))

Missing data

dataFrame1 = dataFrame.reindex(
    index=dates[0:4], columns=list(dataFrame.columns) + ["E"]
)
dataFrame1.loc[dates[0] : dates[1], "E"] = 1
dataFrame1.dropna(how="any")
A B C D E
2022-05-01 -1.259182 0.667831 -0.197721 0.169983 1.0
2022-05-02 0.629798 1.373583 0.686095 -0.492544 1.0


dataFrame1.fillna(value=5)
A B C D E
2022-05-01 -1.259182 0.667831 -0.197721 0.169983 1.0
2022-05-02 0.629798 1.373583 0.686095 -0.492544 1.0
2022-05-03 -0.923828 -0.092225 -0.206072 0.099835 5.0
2022-05-04 0.631935 0.712391 1.455945 0.700102 5.0


pd.isna(dataFrame1)
A B C D E
2022-05-01 False False False False False
2022-05-02 False False False False False
2022-05-03 False False False False True
2022-05-04 False False False False True


Total running time of the script: (0 minutes 0.010 seconds)