[PYTHON] pandas total number of employees missing value complement

Since the securities report showing the total number of employees is published only once a year, there is a missing value in the total number of employees. Therefore, I will try to make up for the gap between them! This time, we supplemented to refer to the number of employees in the previous term.

Current status

スクリーンショット 2019-12-28 12.19.18.png

Target スクリーンショット 2019-12-28 12.22.40.png

python


df['Total number of employees'] = df.groupby(['Ticker'])['Total number of employees'].apply(lambda d: d.fillna(d.interpolate(method='pad', limit=3)))

Recommended Posts

pandas total number of employees missing value complement
Missing value pandas
Calculate the total number of combinations with python
[Kaggle] Summary of pre-processing (statistics, missing value processing, etc.)
"Type Error: Unrecognized value type: <class'str'>" in to_datetime of pandas