[Solved] splitting url and getting values from that URl in columns


try using a str.split and add another str so you can index each row.

data = [{'ID' : '1',
    'URL':  'https://ckd.pdc.com/pdc/73ba5189-94fd-44aa-88d3-6b36aaa69b02/DDA1610095.zip'}]
df = pd.DataFrame(data)



     print(df)
            ID  URL
    0   1   https://ckd.pdc.com/pdc/73ba5189-94fd-44aa-88d...

    #Get the file name and replace zip (probably a more elegant way to do this) 
    df['Zest'] = df.URL.str.split("https://stackoverflow.com/").str[-1].str.replace('.zip','')
    #assign the type into the next column. 
    df['Type'] = df.URL.str.split('.').str[-1]
    print(df)

    ID  URL                                                 Zest       Type
0   1   https://ckd.pdc.com/pdc/73ba5189-94fd-44aa-88d...   DDA1610095 zip

solved splitting url and getting values from that URl in columns