Got a DataFrame, filled with different types: string, int, list I'm now trying to convert every element of each column, that contains a list which isn't longer than one element, to string. I am very well aware of the method apply in connection with a lambda function, yet I don't seem to fully grasp it... Data has been imported from json file with json.load(XXX) and split into different DataFrames also using json_normalize.
DataFrame "infos":
name     town     link                             number
Bob      NY       ["https://www.bobsite.com"]      00184747328859
Alice    MI       ["https://www.alicesite.com"]    00198309458093
Python code:
infos = infos.apply(lambda x: x[0])
# or if just accessing one column
infos = infos.link.apply(lambda x: x[0])
In general doesn't seem the right way to handle this.
Would expect this to be the new DataFrame:
DataFrame "infos":
name     town     link                          number
Bob      NY       https://www.bobsite.com       00184747328859
Alice    MI       https://www.alicesite.com     00198309458093
 
     
     
    