Reputation: 2247
I have a pandas data frame which includes a column with two values in it. That looks like this:
Co-Ordinates |
---|
23.821352807207695, 90.40975987926335 |
23.812076990866696, 90.43087907325717 |
I want to make extra two columns from this existing column using its values which will be looked like this:
Co-Ordinates | Lat | Long |
---|---|---|
23.821352807207695, 90.40975987926335 | 23.821352807207695 | 90.40975987926335 |
23.812076990866696, 90.43087907325717 | 23.812076990866696 | 90.43087907325717 |
I have searched for this problem but didn't found any solution. Or maybe I don't know the exact term to search for. I need help to solve this problem with pandas.
Upvotes: 1
Views: 90
Reputation: 2615
Use this code: Str.split()
df = pd.DataFrame(data = ['23.821352807207695, 90.40975987926335','23.812076990866696, 90.43087907325717'], columns = ['Coordinates'])
df[['Lat','Long']] = df['Coordinates'].str.split(',',expand=True)
df
Output:
Coordinates Lat Long
0 23.821352807207695, 90.40975987926335 23.821352807207695 90.40975987926335
1 23.812076990866696, 90.43087907325717 23.812076990866696 90.43087907325717
Upvotes: 1