0

I have this dataset: enter image description here

And I want to show in the plot only the temperature that has its location_id = 1.

I tried this code:

import matplotlib.pyplot as plt
x = df['local_time'].where(df['location_id'] == 1)
y = df['temperature']

plt.plot(x, y)
plt.xlabel('Local time')
plt.ylabel('Temperature')
plt.title('Weather in London')
plt.show()

And I get this error: TypeError: 'value' must be an instance of str or bytes, not a float

Could you please help me ?

Elisa L.
  • 267
  • 1
  • 8
  • `df2 = df[ df['location_id'] == 1 ]`, then `x = df2[ 'local_time']` and `y = df2['local_time'']` – JohanC Jun 11 '22 at 20:09

1 Answers1

0

this should work

df.set_index('local_time', inplace=True)
df.loc[df.location_id==1].plot()