-2

I have those crime data from San Fransisco. My original data looks like this. san Fransisco data

Long story short, I need to plot dates against time(after performing some filtering) and create a jitter plot. The original format of the date and time column is object. Thats what is what I have done so far.

df.Date = pd.to_datetime(df.Date) 
df.Time = pd.to_datetime(df.Time)
x7=dfdrug.Date.tolist()
y7=dfdrug.Time.tolist()

enter image description here

This is the best I could get, but still I am annoyed by that 7 next to the times. Thank you ;)

Giorgio
  • 1
  • 1

1 Answers1

0

You have converted the Time column to a pd.datetime object as well. The 7 you are seeing is a part of the date (truncated to only show the last part).

If you change your y values to Time objects you will likely get what you are after. E.g:

y7 = df.Time.dt.time.tolist()

John Sloper
  • 1,813
  • 12
  • 14
  • I am afraid when i try to do this I get this error: tzinfo argument must be None or of a tzinfo subclass, not type 'str' – Giorgio Mar 07 '19 at 13:47
  • @Giorgio Sorry, this should be on the dataframe where you have converted it to a datetime. Updating answer now. – John Sloper Mar 07 '19 at 15:02