I have a dataframe having the following keys:
tourist_spot,
nearest landmark,
longitute(landmark),
latitude(landmark),
nearest police station,
longitute(PS),
latitude(PS),
nearest bus stop,
longitute(BS),
latitude(BS),
nearest taxi stand,
longitute(TS),
latitude(TS)
and several other columns like this. What I want to achieve is something like this:
name,
type,
latitude,
longitude,
nearest_to
The name
will have the name of the landmark or PS or BS etc.
Type
will indicate the type of place. For example, PS for police station etc.
latitude
and longitude
will be the locations of each place and nearest_to
will be the name of the tourist_spot
.
Sample data:
tourist_spot ts1
nearest landmark nl1
longitute(landmark) 4
latitude(landmark) 5
nearest police station ps1
longitute(PS) 7
latitude(PS) 8
nearest bus stop bs1
longitute(BS) 9
latitude(BS) 10
nearest taxi stand ts1
longitute(TS) 11
latitude(TS) 12
Please convert into a table like structure. Its tough to make a big table here.
Desired output:
name type longitude latitude nearest_to
nl1 landmark 4 5 ts1
ps1 PS 7 8 ts1
My code so far:
import pandas as pd
df = pd.read_excel("C:\\Users\\NCOG1\\Desktop\\Meghalaya\\Daribokgre.xlsx")
df1 = pd.DataFrame(columns=['name','type_id','longitude','latitude', 'nearby_to'])
df1['name'] = df['Nearest Landmark Name']
df1['type_id'] = df['Nearest Landmark Name']
df1['longitude'] = df['Longitude (of Nearest Landmark)']
df1['latitude'] = df['Latitude (of Nearest Landmark)']
df1['nearby_to'] = df['Name of Tourist Spot']