0

I am working with a data set of different jobs and I added a new blank column called "Distance" and I am trying to add values to this column based of what county the job is, which is under another column called "County"

for i in df_d['County']:
  if i is "Venango":
    df_d.loc['Distance'] = 50

df_d

this is the code a tried with one of the counties to start off. My thought process is that I make a for loop looping over the county column. Then I have if loops in that puts in the correct distance based off of the county name using the .loc function. When I run this there is no errors it just doesn't add the value.

  • 1
    use `numpy.where`, `numpy.select` or `df.loc` with your condition - e.g., `df.loc[df['County'].eq('Venango'), 'Distance'] = 50` – It_is_Chris Jun 21 '23 at 14:42

0 Answers0