0

I have the following DataFrame

I'm trying to get the data every 4 hours from the dataframe using .loc. But its giving me ValueError from it

df.loc[(df['time'].dt.hour in [0, 4, 8, 12, 16, 20]), 'EURUSD_Open']

I would be grateful for some help

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
JMaia
  • 79
  • 4
  • Please include any relevant information [as text directly into your question](https://stackoverflow.com/editing-help), do not link or embed external images of source code or data. Images make it difficult to efficiently assist you as they cannot be copied and offer poor usability as they cannot be searched. See: [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/q/285551/15497888) – Henry Ecker May 27 '21 at 23:02
  • If you need assistance formatting a small sample of your DataFrame for SO see [How to make good reproducible pandas examples](https://stackoverflow.com/q/20109391/15497888). – Henry Ecker May 27 '21 at 23:02
  • All of that said, I'd say you were probably looking for something like `df['time'].dt.hour.isin([0,4,8....])` – Henry Ecker May 27 '21 at 23:04
  • Sorry for my mistakes Henry, thank you very much for your help it worked :) – JMaia May 27 '21 at 23:16

0 Answers0