Find the highest and lowest value for a time frame

floss

(Not a duplicate question)

I have the following dataset with Gmt time and Open value

Gmt time, Open
2018-01-01 00:00:00,2.7321
2018-01-01 00:01:00,2.7323
2018-01-01 00:02:00,2.7322
2018-01-01 00:03:00,2.7321
2018-01-01 00:04:00,2.7323
2018-01-01 00:05:00,2.7325
2018-01-01 00:06:00,2.7322
...., ....
2018-12-31 23:59:00,3.1463

The Gmt time is a DateTime with yyyy-mm-dd hh:mm:ss given above. You can see that each data point is 1 minute apart.

I want to find the highest Open value and the lowest Open value for every single day(24hours time frame). Eg: 2018-01-01 00:00:00 to 2018-01-01 23:59:00

My new DataFrame should look like this:

Gmt time, Open-high, Open-Low
2018-01-01 ,2.7321, ,2.7321
2018-01-02 ,2.7321, ,2.7321
2018-01-03 ,2.7321, ,2.7321
...., ...., ...., ....
2018-12-31 ,2.7321, ,2.7321

Could you please let me know how can I do this in pandas?

Quang Hoang

I would be surprised if it is not a dup:

df.groupby(df['Gmt time'].dt.floor('D')).Open.agg(['min','max']).reset_index()

output:

    Gmt time     min     max
0 2018-01-01  2.7321  2.7325
1 2018-12-31  3.1463  3.1463

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Java sort HashMap by highest value, then lowest key

How to find the highest value of a column in a data frame in R?

Fastest way to find second (third...) highest/lowest value in vector or column

How to find the highest and lowest number with JS?

How to find highest and lowest value and aggregate into a string in Pandas, Pysimplegui

Find highest and lowest number from the string of numbers

Highest and lowest value of nested lists using recursion

datetime lowest value find

Need formula to get lowest and highest value of a year

How to find lowest value at the time (lap records) in MySQL?

Highest - Lowest value sort Textboxes

LINQ - find between lowest and highest string

Select highest/lowest value for x in Data Object

Mark highest and lowest value in HTML table

Find the lowest / highest key of a distributed map

How to I find lowest and highest value of this array (java)

Find the highest and lowest value locations within an interval on a column?

Finding highest and lowest value of rainfall in Raptor

Find time difference between highest and lowest value in data frame and sort by factor

How to find the highest and lowest product price

Get user with highest and lowest value

find the highest and lowest number in array with JOptionPane

FIND THE HIGHEST AND LOWEST SALARY

How to efficiently find the Lowest Key of the Highest Value in a map with a constraint that it can contain duplicate Values?

How to find the lowest and highest date based on certain value in another column?

Find the lowest and highest NUMBERS in a collection

How to find highest and lowest value on substrings?

Find time of highest and lowest candles

Find Nth highest/lowest values in Pine