Skip to content
Advertisement

Split data frame in python based on one parameter shape

I have a data frame which is like the following :

JavaScript

Dataframe

In this data frame, there are many repeated rows for example the first row is repeated more than 1000 times, and so on for the other rows

when I plot the time distribution I got that figure which shows that the frequency of the time parameter

JavaScript

Time distribution

My question is how can I take the data only in the following red rectangular for example at time = 0.006 and frequency = 0.75 1e6 ( check the following pic )

Red rectangular

Advertisement

Answer

Note: InPlace of target you have to write time as your column name Is time,or change column name to target

JavaScript

You have To pass your data frame, x-intercept of the graph, y-intercept of graph to calRows(df,x,y) function which will return the number of rows to take for each target.

JavaScript

takeFeatures(df,rows,x) function will take dataframe, rows (result of first function), x-intercept of graph and will return you the final dataframe.

JavaScript

Calling takeFeature() Function

JavaScript

Your Final DataFrame will have the Values ThatYou expected in Graph And After Plotting this final dataframe you will get like this graph enter image description here

Advertisement