Issue
Ok so I have a dataset/frame with pandas and I want to select one row per minute to get a more accurate view of the simulation. As the times in the dataframe are too close together.
req_columns = [4,5,6, 9]
df = pd.read_excel('Flt0052UV.xlsx', skiprows = range(1,33656), usecols= req_columns)
df = df[~df.Longitude.isnull()]
here is how I currently select the data any help would be greatly appreciated.
Solution
Use resample()
on your datetime with first()
.
import pandas as pd
df = pd.DataFrame(data=[i for i in range(3600)], index=pd.date_range(start='01/01/2022', periods=3600, freq='s'), columns=['data'])
df = df.resample('1min').first()
Output:
data
2022-01-01 00:00:00 0
2022-01-01 00:01:00 60
2022-01-01 00:02:00 120
2022-01-01 00:03:00 180
... ...
Answered By - Stu Sztukowski
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.