Python Forum
Select data from between two timestamps
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select data from between two timestamps
#1
Hi,

I am currently reading data from a .dat file as CSV.
With the script below i manage to get data from the source, but i cant get data when i select to get data between 2 timestamps.
For example data between 2020-01-20 12:00:00 and 2020-01-25 12:15:00
With the script below i get the whole datarange from the source, see second field showing the output from the script.
Maybe someone have a hint on how to accomplish that?

Thanks.

import pandas as pd
import numpy as np
import datetime as dt
import csv

df = pd.read_csv("C:\\Users\\Makada\\Desktop\\CR1000_Table1 - kopie .dat",
                 skiprows=1,
                 index_col=['TIMESTAMP'],
                 parse_dates=True,
                 header=0,
                 usecols=['TIMESTAMP','WS_kph_Max'])

df['2020-01-20 20:59:00':'2020-01-22 21:01:00']

print(df)
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
=========== RESTART: C:\Users\Makada\Desktop\pppooooooooooooooooo.py ===========
                          WS_kph_Max
TIMESTAMP                           
TS                   kilometers/hour
NaN                              Max
2020-01-19 20:59:00            4.609
2020-01-19 21:00:00            4.294
2020-01-19 21:01:00             4.24
...                              ...
2020-01-29 16:30:00            20.09
2020-01-29 16:31:00            30.92
2020-01-29 16:32:00            24.65
2020-01-29 16:33:00            21.34
2020-01-29 16:34:00            25.74

[14138 rows x 1 columns]
Reply


Messages In This Thread
Select data from between two timestamps - by Makada - Jan-29-2020, 08:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Select column between to dates CSV data PythonJD 0 1,794 Apr-14-2020, 12:22 PM
Last Post: PythonJD
  select data based on indice Staph 4 2,552 Jul-15-2019, 02:05 AM
Last Post: scidam
  how to select particular rows data from a array raady07 3 4,426 Mar-06-2017, 02:21 AM
Last Post: raady07

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020