1

let us suppose we have following information about georgia country

georgia =pd.read_excel("https://geostat.ge/media/52173/ganawileba-sacxovrebeli-adgilis-mixedviT.xls",skiprows=[0])
georgia.head()

result is :

enter image description here

as you see there is missing informations about years, but we can see that given year is divided into quarters, therefore logical will be fill missed data with corresponding year grouped by quarter right ? for instance if we try :

georgia.groupby('კვარტალი')['წელი'].head()

which stands show year(წელი) for each quarter(კვარტალი) result would be :

0     2014.0
1        NaN
2        NaN
3     2015.0
4        NaN
5        NaN
6        NaN
7     2016.0
8        NaN
9        NaN
10       NaN
11    2017.0
12       NaN
13       NaN
14       NaN
15    2018.0
16       NaN
17       NaN
18       NaN
19    2019.0
Name: წელი, dtype:

float64 how can i extract use given information for filling missed value? i think it should be super easy but i can't guess and please give hint

data science
  • 215
  • 9

1 Answers1

1

Use:

georgia['წელი'] = georgia['წელი'].ffill()
georgia.groupby('კვარტალი')['წელი'].head()
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252