0

I'm trying to select a range in a DataFrame by date (the column 'Start Time'). I've converted the column to datetime64[ns] but I'm getting 'AttributeError: 'Series' object has no attribute 'date_range' regardless. Any suggestions?

data['Start Time'] = pd.to_datetime(data['Start Time'])
data['Start Time'].date_range(start='1/1/2017', end='1/15/2017')
Chris Macaluso
  • 1,372
  • 2
  • 14
  • 33
  • You can try data['Start Time'][data['Start Time'].isin(pd.date_range(start='1/1/2017', end='1/15/2017'))] – Felipe D. Jul 23 '18 at 01:53
  • Thanks! I'm not getting any errors with that which is good. Its still not quite working though. I think part of the problem is the column 'Start Time' also has a time stamp, like so: '1/4/2017 8:27'. Should I try to remove the time for now if that doesn't matter for me at the moment? Or should it still be filtering regardless? Can I use wildcards? – Chris Macaluso Jul 23 '18 at 02:15
  • Happy to help = ) What do you mean when you say "it isn't working"? What's the output you wanted to get? – Felipe D. Jul 23 '18 at 02:21

0 Answers0