Question

I need help to write a code in python to do the following: I need to...

I need help to write a code in python to do the following:

I need to extract only the start hour from each row in the the column below into a separate column.

This is a part of database and the School_Hours column is having the following info:

School_Hours
08:00 AM-03:00 PM
08:15 AM-03:15 PM
08:30 AM-03:30 PM
7:45 AM - 2:45 PM
7:30 AM-2:30 PM
7:45 AM - 2:45 PM
8:30 AM - 2:55 PM
08:30 AM-03:30 PM
8:30 AM-3:30 PM
08:00 AM-03:00 PM
8:00 am-3:30 pm
9:00 AM - 4:15 PM
7:00 am-3:00 pm
08:30 AM-03:30 PM
08:00 AM-03:00 PM
08:45 AM-03:45 PM
8:00 AM-3:30 PM
8:00 AM-3:30 PM
7:45 AM-2:45 PM
07:45 AM-02:45 PM
8:00 am-3:30 pm
9:00 AM - 4:08 PM
7:50 am-3:30 pm
8:00 AM - 3:30 PM
08:30 AM-03:30 PM
7:15a.m.-2:45p.m.
8:00 am-3:30 pm
9:00 AM - 4:00 Pm
08:00 AM-03:00 PM
8:00 AM - 3:13 PM
08:15 AM-03:15 PM
M, T, W, Th: 7:45 AM-3:05 PM F: 7:45 AM-2:07 PM
08:45 AM-03:45 PM
7:30 AM-3:00 PM
7:45 AM - 2:45 PM
08:00 AM-03:00 PM
7:45 AM - 3:00 PM
08:45 AM-03:45 PM
07:45 AM-02:45 PM
8:00 am-3:00 pm
07:45 AM-02:45 PM
8:00 AM - 3:30 PM
8:45 AM-3:45 PM
08:45 AM-03:45 PM
08:00 AM-03:00 PM
8:00 am-3:30 pm
8:00 AM-3:00 PM
8:30 AM-4:00 PM
8:00 AM - 3:15 PM
08:00 AM-03:00 PM
8:00 AM-3:23 PM
8:00 AM-3:00 PM
7:45 AM - 2:45 PM
8:00 AM - 3:30 PM
7:30 AM-2:45 PM
7:45 a.m. - 3:45 p.m.
8:30 AM - 4:00 PM
7:45 AM - 3:41 PM
9:00 AM-4:00 PM
07:45 AM-02:45 PM
07:30 AM-02:30 PM
8:45 AM-3:45 PM
8:00 AM-3:55 PM
07:45 AM-02:45 PM
07:45 AM-02:45 PM
8:00 am-3:30 pm
08:30 AM-03:30 PM
8:30 AM-4:30 PM
8:45 AM - 4:00 PM
7:30 AM-2:30 PM
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import pandas as pd

# Create a dataframe from the database - Here I have take an example of a case that the database is Microsoft Access where the required query and fields are defined also the required pyodbc import
data = pd.DataFrame(SQL_Query, columns=['field1','field2',...])

# Dropping null value columns

data.dropna(inplace = True)

# Splitting the column at  '-' into two parts

datasplit = data["School_Hours"].str.split("-", n = 1, expand = True)

# Getting the first Part

m = datasplit[0]

# Getting the Start Hour and creating the required column.

data[starthour] = m[-7:]

Add a comment
Know the answer?
Add Answer to:
I need help to write a code in python to do the following: I need to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following time series represents the hourly customer volume for a small dining establishment. Hour Customer...

    The following time series represents the hourly customer volume for a small dining establishment. Hour Customer volume 7:00 a.m. 5 8:00 a.m. 5 9:00 a.m. 15 10:00 a.m. 20 11:00 a.m. 30 12:00 noon 50 1:00 p.m. 45 2:00 p.m. 30 3:00 p.m. 40 4:00 p.m. 20 5:00 p.m. 10 Use an exponential smoothing model with α = 0.50 to produce forecasts for this time series.  Assume that the forecast for the 7:00 a.m. time slot is 5 customers.   What recommendations...

  • python 3 beginner top question please In Boilerville, a bicycle can be rented between 8:00 am...

    python 3 beginner top question please In Boilerville, a bicycle can be rented between 8:00 am unti 9.0 0 are prot hour from 8:00 am until 3:30 pm. From 3:30 pm until 9:00o Partial ho bike, and they do not rent bikes before 8:00 am or Define a function named q50 that prm. The charge for each bike is $1 75p pm the rate is $2.50 an hour. These rates are per after 9:00 pm. Partial hours accepts the number...

  • please, i need help as soon as possible. please, i need help as soon as possible....

    please, i need help as soon as possible. please, i need help as soon as possible. B- AutoSave Of H File Home Insert Assignment2 (1) - Excel Page Layout Formulas Data Parta Draw fo Review A1 x 1 Parta 2 Pattern: Time Series Plot SUSAN 19 Part 6 20 Regression Model: 21 Estimated Nitrogen Dioxide 9-10am: 22 Estimated Nitrogen Dioxide 3-4pm: 24. Part 25 Regression Model: 26 Estimated Nitrogen Dioxide 9-10am: 27 Estimated Nitrogen Dioxide 3-4pm: 29 Part 01 02...

  • 51. A large pharmaceutical company with distribution centres in Canada and the United States has its call centre lo...

    51. A large pharmaceutical company with distribution centres in Canada and the United States has its call centre located in Mississauga, Ontario. There are 20 customer service representatives answering calls from 8 a.m to 9 p.m. through the week, and from 9 am. to 5 p.m. on Saturdays. The call centre reported the number of calls waiting to be answered between the hours of 9 a.m. and 10 am over a 50-day period as shown below. Sum marize the data...

  • Need help writing a program that meets pseudocode and criteria . Txt File below input.txt file...

    Need help writing a program that meets pseudocode and criteria . Txt File below input.txt file data 05 11/30/16 03 12/07/16 05 12/07/16 05 12/08/16 01 12/10/16 07 12/11/16 07 12/14/16 06 12/15/16 02 12/21/16 05 12/21/16 06 12/22/16 07 12/22/16 08 12/23/16 07 12/23/16 07 12/23/16 07 12/23/16 08 12/24/16 08 12/24/16 07 12/24/16 03 12/26/16 05 12/26/16 07 12/28/16 04 12/29/16 07 01/01/17 06 01/03/17 07 01/03/17 08 01/05/17 05 01/10/17 04 01/17/17 08 01/17/17 07 01/18/17 07...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program that creates a dictionary named rooms containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (Key) Room Number (Value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary named instructors containing course numbers and the names of the instructors that teach...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a program that creates a dictionary named rooms containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (Key) Room Number (Value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary named instructors containing course numbers and the names of the instructors that teach...

  • Wichita's famous Sethi Restaurant is open 24 hours a day. Servers report for duty at 3...

    Wichita's famous Sethi Restaurant is open 24 hours a day. Servers report for duty at 3 A.M., 7 A.M., 11 A.M., 3 PM., 7 PM.,or 11 PM., and each works an 8-hour shift. The following table shows the minimum number of workers neede the 6 periods into which the day is divided: during Decision vairable x, number of workers reporting for the start of working period i, where i-1, 2, 3, 4, 5, or 6 Period Time ???.-7A.M 7 A.M.-11...

  • I need the answer to #2 listed above. This is the code I have come up...

    I need the answer to #2 listed above. This is the code I have come up with, and it is wrong. I am new to this and need help. group by sust.cida Q2 (7 Points) Show customer id (CID) for customers who have spent 30,000 or more with the company in 2019. Money is considered "spent" when the entire work order is completed as recorded in workorder.completionDate. (Correct query will find customer 2). Use ONE SQL statement. select workarder.id from...

  • Complete a time card for the employee below: Adam Spruce (SSN 565-56-5656) worked six days during...

    Complete a time card for the employee below: Adam Spruce (SSN 565-56-5656) worked six days during the week of 01/15/2018 through 01/21/2018 (he was off work on Tuesday). He arrived at 9:00 a.m. each day (except Friday, when he was four minutes early, and Sunday, when he was two minutes late). He left for lunch at 12:30 p.m. each day (except Wednesday, when he left at 12:28 p.m., and Thursday, when he left at 1:01 p.m.), and arrived back at...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT