Convert Julian date column to Gregorian in python pandas

I have a group of columns of type "julian date" in pandas. What would be the best way to convert them to gregorian dates. My DataFrame looks like

    CODE     START_DATE     END_DATE
0  00200         115001       115365
1  00200         115001       115365
2  00200         115001       115365
3  00200         115001       115365
4  00200         115001       115365

I would like to convert the START_DATE and END_DATE columns to gregorian / regular datetime.

In sql, I would use below -

UPDATE Table1 set
DATE_NEW = CASE WHEN ltrim(rtrim(START_DATE)) = 0 THEN '1900-01-01' 
    WHEN ltrim(rtrim(START_DATE)) IS NULL THEN NULL    
    ELSE (CAST(DATEADD(dayofyear , ltrim(rtrim(START_DATE)) % 1000 - 1,DATEADD(year, ltrim(rtrim(START_DATE)) / 1000 , '1900-01-01')) as date)) END 

Please offer. Thank.

+4
source share

All Articles