Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 2688
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 1, 20222022-06-01T10:39:59+00:00 2022-06-01T10:39:59+00:00

python – Pandas – How to find number of equipment failures and the corresponding downtime for each failure

  • 0

[ad_1]

I have some test data which looks like this:

test_data = {'equipment_barcode': ['0001', '0001', '0001', '0001', '0002', '0002', '0002', '0002'], 
         'date': ['2022-04-16', '2022-04-17', '2022-04-18', '2022-04-19', '2022-05-13', '2022-05-14', '2022-05-15', '2022-05-16'],
         'downtime_minutes':[1200, 240, 1440, 600, 360, 1440, 1440, 180]}

I have converted this into a pandas dataframe:

df = pd.DataFrame(test_data)

print(df)

    equipment_barcode   date          downtime_minutes
0   0001                2022-04-16    1200
1   0001                2022-04-17    240
2   0001                2022-04-18    1440
3   0001                2022-04-19    600
4   0002                2022-05-13    360
5   0002                2022-05-14    1440
6   0002                2022-05-15    1440
7   0002                2022-05-16    180

There are 1,440 minutes in one day. This information is required to calculate the NUMBER of faults. A fault may occur over consecutive number of days and thus will still be counted as ONE fault only.

The task is to find the number of faults for each equipment_barcode. For example equipment 0001 had 2 faults [one fault on 16th of April lasting for 1200 minutes and one fault on 17th-19th of April lasting for 2280 minutes(240 + 1440 + 600)].

For added clarity; equipment 0002 had 1 fault [fault on 13th-16th of May lasting for 3420 minutes (360 + 1440 + 1440 + 180)].

In the end I would like a resulting dataframe that shows something like this:

    equipment_barcode   fault_number    total_downtime_minutes
0   0001                1               1200
1   0001                2               2280
2   0002                1               3420

[ad_2]

  • 0 0 Answers
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 2 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 4 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 3 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.