필터 지우기
필터 지우기

How to fill missing dates (NaT) with the next date ?

조회 수: 1 (최근 30일)
Namrata Goswami
Namrata Goswami 2020년 12월 17일
답변: Image Analyst 2020년 12월 17일
My table looks like :
ID Amount Date
12 100 Jan-2020
12 400 NaT
12 100 NaT
12 500 NaT
12 100 NaT
14 900 Jan-2020
14 100 NaT
14 500 NaT
I need to fill the missing dates with the following month-year from the previous:
ID Amount Date
12 100 Jan-2020
12 400 Feb-2020
12 100 Mar-2020
12 500 Apr-2020
12 100 May-2020
14 900 Jan-2020
14 100 Feb-2020
14 500 Mar-2020
I tried using fillmissing, within each group, but doesn't work:
T2 = varfun(@(x) fillmissing(x,'linear'), T1,'groupingvariables',{'ID'},'InputVariables',{'Date'});

답변 (1개)

Image Analyst
Image Analyst 2020년 12월 17일
I'd just run down the column and detect if the value is a NaT. If it is, replace it by the last good month plus 1. Attach your table if you need more help.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by