Created
March 6, 2022 02:25
VRP - 002 - Get Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read data from csv file containing all US states and turn this into a pandas dataframe | |
states=pd.read_csv("https://raw.githubusercontent.com/LucasDiogo96/Routing-Optimizer/main/statelatlong.csv") | |
# Remove alaska and hawaii because they are too far from the others | |
states = states.query('State not in ["AK","HI"]') | |
# Creating a vehicle dataset | |
data = {'Name': ['Vehicle 0','Vehicle 1','Vehicle 2','Vehicle 3','Vehicle 4','Vehicle 5'], | |
'Plate': ['MIY208','UH1BCD','7GDE215','6543MS','8DFG468','D48541T'] | |
} | |
# Creating a dataframe | |
vehicles = pd.DataFrame(data, columns = ['Name','Plate']) | |
# Uses a sampling of state data to be the location of our vehicles | |
sample = states.sample(n=6,random_state=1) | |
# Unsamples state data | |
states.drop(sample.index,inplace=True) | |
# Join both | |
vehicles = vehicles.join(sample.reset_index(drop=True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment