Deleting rows between multiple sets of time stamps

Deleting rows between multiple sets of time stamps

I have a DataFrame that has time stamps in the form of (yyyy-mm-dd hh:mm:ss). I'm trying to delete data between two different time stamps. At the moment I can delete the data between 1 range of time stamps but I have trouble extending this to multiple time stamps.

I have a DataFrame that has time stamps in the form of (yyyy-mm-dd hh:mm:ss). I'm trying to delete data between two different time stamps. At the moment I can delete the data between 1 range of time stamps but I have trouble extending this to multiple time stamps.

For example, with the DataFrame I can delete a range of rows (e.g. 2015-03-01 00:20:00 to 2015-08-01 01:10:00) however, I'm not sure how to go about deleting another range alongside it. The code that does that is shown below.

index_list= df.timestamp[(df.timestamp >= "2015-07-01 00:00:00") & (df.timestamp <= "2015-12-30 23:50:00")].index.tolist()

df1.drop(df1.index[index_list1, inplace = True)

The DataFrame extends over 3 years and has every day in the 3 years included. I'm trying to delete all the rows from months July to December (2015-07-01 00:00:00 to 2015-12-30 23:50:00) for all 3 years.

I was thinking that I create a helper column that gets the Month from the Date column and then drops based off the Month from the helper column.

I would greatly appreciate any advice. Thanks!

Edit: I've added in a small summarised version of the DataFrame. This is what the intial DataFrame looks like.

df    Date                   v
    2015-01-01 00:00:00     30.0
    2015-02-01 00:10:00     55.0
    2015-03-01 00:20:00     36.0
    2015-04-01 00:30:00     65.0
    2015-05-01 00:40:00     35.0
    2015-06-01 00:50:00     22.0
    2015-07-01 01:00:00     74.0
    2015-08-01 01:10:00     54.0
    2015-09-01 01:20:00     86.0
    2015-10-01 01:30:00     91.0
    2015-11-01 01:40:00     65.0
    2015-12-01 01:50:00     35.0

To get something like this

df    Date                   v
    2015-01-01 00:00:00     30.0
    2015-02-01 00:10:00     55.0
    2015-03-01 00:20:00     36.0
    2015-05-01 00:40:00     35.0
    2015-06-01 00:50:00     22.0
    2015-11-01 01:40:00     65.0
    2015-12-01 01:50:00     35.0

Where time stamps "2015-07-01 00:20:00 to 2015-10-01 00:30:00"and "2015-07-01 01:00:00 to 2015-10-01 01:30:00" are removed. Sorry if my formatting isn't up to standard.

python pandas

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Python Pandas Objects - Pandas Series and Pandas Dataframe

In this post, we will learn about pandas’ data structures/objects. Pandas provide two type of data structures:- ### Pandas Series Pandas Series is a one dimensional indexed data, which can hold datatypes like integer, string, boolean, float...

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

Python Pandas Tutorial - Data Analysis with Python Pandas

Python Pandas Tutorial - Data Analysis with Python Pandas will help you get started with Python Pandas Library for various applications including Data analysis. You'll learn: Introduction to Pandas; DataFrames and Series; How To View Data? Selecting Data; Handling Missing Data; Pandas Operations; Merge, Group, Reshape Data; Time Series And Categoricals; Plotting Using Pandas

PYTHON Pandas Basic Functions

PYTHON Pandas Basic Functions. So far, we have learned the three pandas data structure and how to create them. Due to its importance in real-time data processing, we will focus on dataframe objects right now and mention a few other data structures.

Python Pandas Tutorial - Data Analysis with Python Pandas

Python Pandas Tutorial will help you get started with Python Pandas Library for various applications including Data analysis. Introduction to Pandas. DataFrames and Series. How To View Data? Selecting Data. Handling Missing Data. Pandas Operations. Merge, Group, Reshape Data. Time Series And Categoricals. Plotting Using Pandas