I have a csv file with columns like this
I need to separate column (B) values into separate columns and multiple rows like this
This is what I tried (the data here in below code is same as csv data above) and did not work
data = [{"latlong":'{lat: 15.85173248 , lng: 78.6216129},{lat: 15.85161765 , lng: 78.61982138},{lat: 15.85246304 , lng: 78.62031075},{lat: 15.85250474 , lng: 78.62034441},{lat: 15.85221891 , lng: 78.62174507},', "Id": 1},
{"latlong": '{lat: 15.8523723 , lng: 78.62177758},{lat: 15.85236637 , lng: 78.62179098},{lat: 15.85231281 , lng: 78.62238316},{lat: 15.8501259 , lng: 78.62201676},', "Id":2}]
df = pd.DataFrame(data)
df
df.latlong.apply(pd.Series)
This works in this case
data1 = [{'latlong':[15.85173248, 78.6216129, 1]},{'latlong': [15.85161765, 78.61982138, 1]},{'latlong': [15.85246304, 78.62031075, 1]},
{'latlong': [15.85250474, 78.62034441, 1]}, {'latlong': [15.85221891, 78.62174507, 1]},{'latlong': [15.8523723, 78.62177758, 2]},
{'latlong': [15.85236637, 78.62179098, 2]}, {'latlong': [15.85231281, 78.62238316, 2]},{'latlong': [15.8501259,78.62201676, 2]}]
df1 = pd.DataFrame(data1)
df1
df1 = df1['latlong'].apply(pd.Series)
df1.columns = ['lat', 'long', 'Id']
df1
How can I achieve this with Python ?
New to python. I tried following links... Could not understand how to apply it to my case. Splitting dictionary/list inside a Pandas Column into Separate Columns