A python code to summarize data of one column based on ordered value of another columnTraverse a list in reverse order in PythonWhy can't Python parse this JSON data?Why does Python code run faster in a function?Adding new column to existing DataFrame in Python pandasGet unique values from a list in pythonHow to change the order of DataFrame columns?“Large data” work flows using pandasSelect rows from a DataFrame based on values in a column in pandasDeleting DataFrame row in Pandas based on column valuepython: convert pandas categorical values to integer when reading csv in chunks

Is there any reason to change the ISO manually?

Label "Alto en grasa saturada, sal, ..." should there also be Alta?

'Hard work never hurt anyone' Why not 'hurts'?

Vimscript - Surround word under cursor with quotes

Was Rosie the Riveter sourced from a Michelangelo painting?

Can anyone find an image of Henry Bolingbroke's Sovereygne Feather Seal?

Fantasy Military Arms and Armor: the Dwarven Grand Armory

What would a biological creature need in order to see into the future?

What's this constructed number's starter?

What are some countries where you can be imprisoned for reading or owning a Bible?

How do I make my fill-in-the-blank exercise more obvious?

In-universe, why does Doc Brown program the time machine to go to 1955?

GFI outlets tripped after power outage

Why does the seven segment display have decimal point at the right?

Are there mathematical concepts that exist in the fourth dimension, but not in the third dimension?

Does POSIX guarantee the paths to any standard utilities?

What is the majority of the UK Government as of 2019-09-04?

How many people can lift Thor's hammer?

Is the interior of a Bag of Holding actually an extradimensional space?

How were the names on the memorial stones in Avengers: Endgame chosen, out-of-universe?

Why is a pressure canner needed when canning?

Do 643,000 Americans go bankrupt every year due to medical bills?

How do I anonymously report the Establishment Clause being broken?

What's the eccentricity of an orbit (trajectory) falling straight down towards the center?



A python code to summarize data of one column based on ordered value of another column


Traverse a list in reverse order in PythonWhy can't Python parse this JSON data?Why does Python code run faster in a function?Adding new column to existing DataFrame in Python pandasGet unique values from a list in pythonHow to change the order of DataFrame columns?“Large data” work flows using pandasSelect rows from a DataFrame based on values in a column in pandasDeleting DataFrame row in Pandas based on column valuepython: convert pandas categorical values to integer when reading csv in chunks






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am dealing with a data where I have two columns, lets say "time" & "activity".

The time data is a python datetime value in ascending order whereas the activity takes numeric value starting from 0 till 5.

The catch about the activity variable is that it has repeated ordered values from 0 to 5 & back to 0 again.

For e.g. 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0.



The dataset(a snippet of 17 observations) looks like:



time: t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17

activity: 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0



Now, my question is : HOW DO I CALCULATE THE TIME TAKEN FOR THE ACTIVITY TO REACH FROM 0 TO 5 FOLLOWED BY 5 TO 0. I WANT TO DO IT IN PYTHON.



I explored certain areas but not fruitful enough to be shared.



The result I am looking for would typically create 2 objects like:

1. timefrom0to5= (t8-t1) secs

2. timefrom5to0= (t17-t9) secs



Any help would be highly appreciable.

Thanks in advance.










share|improve this question



















  • 1





    Do you have any ideas of your own? Have you written any code at all yet? This is a site for asking specific questions about programming, not a place to say "how do I solve this problem?", or "please write this code for me". You need to get started yourself and get to a place that shows you've at least thought about the problem yourself. Then you can come back here for specific help. Have you written Python code before?

    – Steve
    Mar 28 at 4:29












  • So you can assume what...that there will be two 5s in the sequence, they will be the largest values, and you want to split the times between the two of them? Or does your code need to figure what the highest numbers are, and how many of them there are?

    – Steve
    Mar 28 at 4:40











  • Welcome to Stack Overflow! Please read what this site is about and "How to ask" before asking a question.

    – Steve
    Mar 28 at 4:44


















0















I am dealing with a data where I have two columns, lets say "time" & "activity".

The time data is a python datetime value in ascending order whereas the activity takes numeric value starting from 0 till 5.

The catch about the activity variable is that it has repeated ordered values from 0 to 5 & back to 0 again.

For e.g. 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0.



The dataset(a snippet of 17 observations) looks like:



time: t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17

activity: 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0



Now, my question is : HOW DO I CALCULATE THE TIME TAKEN FOR THE ACTIVITY TO REACH FROM 0 TO 5 FOLLOWED BY 5 TO 0. I WANT TO DO IT IN PYTHON.



I explored certain areas but not fruitful enough to be shared.



The result I am looking for would typically create 2 objects like:

1. timefrom0to5= (t8-t1) secs

2. timefrom5to0= (t17-t9) secs



Any help would be highly appreciable.

Thanks in advance.










share|improve this question



















  • 1





    Do you have any ideas of your own? Have you written any code at all yet? This is a site for asking specific questions about programming, not a place to say "how do I solve this problem?", or "please write this code for me". You need to get started yourself and get to a place that shows you've at least thought about the problem yourself. Then you can come back here for specific help. Have you written Python code before?

    – Steve
    Mar 28 at 4:29












  • So you can assume what...that there will be two 5s in the sequence, they will be the largest values, and you want to split the times between the two of them? Or does your code need to figure what the highest numbers are, and how many of them there are?

    – Steve
    Mar 28 at 4:40











  • Welcome to Stack Overflow! Please read what this site is about and "How to ask" before asking a question.

    – Steve
    Mar 28 at 4:44














0












0








0








I am dealing with a data where I have two columns, lets say "time" & "activity".

The time data is a python datetime value in ascending order whereas the activity takes numeric value starting from 0 till 5.

The catch about the activity variable is that it has repeated ordered values from 0 to 5 & back to 0 again.

For e.g. 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0.



The dataset(a snippet of 17 observations) looks like:



time: t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17

activity: 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0



Now, my question is : HOW DO I CALCULATE THE TIME TAKEN FOR THE ACTIVITY TO REACH FROM 0 TO 5 FOLLOWED BY 5 TO 0. I WANT TO DO IT IN PYTHON.



I explored certain areas but not fruitful enough to be shared.



The result I am looking for would typically create 2 objects like:

1. timefrom0to5= (t8-t1) secs

2. timefrom5to0= (t17-t9) secs



Any help would be highly appreciable.

Thanks in advance.










share|improve this question














I am dealing with a data where I have two columns, lets say "time" & "activity".

The time data is a python datetime value in ascending order whereas the activity takes numeric value starting from 0 till 5.

The catch about the activity variable is that it has repeated ordered values from 0 to 5 & back to 0 again.

For e.g. 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0.



The dataset(a snippet of 17 observations) looks like:



time: t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17

activity: 0,0,1,2,3,3,4,5,5,4,4,3,2,1,1,0,0



Now, my question is : HOW DO I CALCULATE THE TIME TAKEN FOR THE ACTIVITY TO REACH FROM 0 TO 5 FOLLOWED BY 5 TO 0. I WANT TO DO IT IN PYTHON.



I explored certain areas but not fruitful enough to be shared.



The result I am looking for would typically create 2 objects like:

1. timefrom0to5= (t8-t1) secs

2. timefrom5to0= (t17-t9) secs



Any help would be highly appreciable.

Thanks in advance.







python






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 4:07









SNB13SNB13

53 bronze badges




53 bronze badges










  • 1





    Do you have any ideas of your own? Have you written any code at all yet? This is a site for asking specific questions about programming, not a place to say "how do I solve this problem?", or "please write this code for me". You need to get started yourself and get to a place that shows you've at least thought about the problem yourself. Then you can come back here for specific help. Have you written Python code before?

    – Steve
    Mar 28 at 4:29












  • So you can assume what...that there will be two 5s in the sequence, they will be the largest values, and you want to split the times between the two of them? Or does your code need to figure what the highest numbers are, and how many of them there are?

    – Steve
    Mar 28 at 4:40











  • Welcome to Stack Overflow! Please read what this site is about and "How to ask" before asking a question.

    – Steve
    Mar 28 at 4:44













  • 1





    Do you have any ideas of your own? Have you written any code at all yet? This is a site for asking specific questions about programming, not a place to say "how do I solve this problem?", or "please write this code for me". You need to get started yourself and get to a place that shows you've at least thought about the problem yourself. Then you can come back here for specific help. Have you written Python code before?

    – Steve
    Mar 28 at 4:29












  • So you can assume what...that there will be two 5s in the sequence, they will be the largest values, and you want to split the times between the two of them? Or does your code need to figure what the highest numbers are, and how many of them there are?

    – Steve
    Mar 28 at 4:40











  • Welcome to Stack Overflow! Please read what this site is about and "How to ask" before asking a question.

    – Steve
    Mar 28 at 4:44








1




1





Do you have any ideas of your own? Have you written any code at all yet? This is a site for asking specific questions about programming, not a place to say "how do I solve this problem?", or "please write this code for me". You need to get started yourself and get to a place that shows you've at least thought about the problem yourself. Then you can come back here for specific help. Have you written Python code before?

– Steve
Mar 28 at 4:29






Do you have any ideas of your own? Have you written any code at all yet? This is a site for asking specific questions about programming, not a place to say "how do I solve this problem?", or "please write this code for me". You need to get started yourself and get to a place that shows you've at least thought about the problem yourself. Then you can come back here for specific help. Have you written Python code before?

– Steve
Mar 28 at 4:29














So you can assume what...that there will be two 5s in the sequence, they will be the largest values, and you want to split the times between the two of them? Or does your code need to figure what the highest numbers are, and how many of them there are?

– Steve
Mar 28 at 4:40





So you can assume what...that there will be two 5s in the sequence, they will be the largest values, and you want to split the times between the two of them? Or does your code need to figure what the highest numbers are, and how many of them there are?

– Steve
Mar 28 at 4:40













Welcome to Stack Overflow! Please read what this site is about and "How to ask" before asking a question.

– Steve
Mar 28 at 4:44






Welcome to Stack Overflow! Please read what this site is about and "How to ask" before asking a question.

– Steve
Mar 28 at 4:44













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390009%2fa-python-code-to-summarize-data-of-one-column-based-on-ordered-value-of-another%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390009%2fa-python-code-to-summarize-data-of-one-column-based-on-ordered-value-of-another%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript