Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python write functions(use pandas) 1.read_frame: Read a csv file that looks like this: into a DataFrame that looks like this: and return it. Use

Use python write functions(use pandas)

1.read_frame: Read a csv file that looks like this:

into a DataFrame that looks like this:

and return it. Use the pd.read_csv function. You will need to read the documentation to figure out what arguments to pass to make it work. The data in this file are from http://aa.usno.navy.mil/cgi- bin/aa_rstablew.pl?ID=AA&year=2018&task=0&state=AZ&place=Tucson. You should take a look at this link so you understand what the numbers represent. Pandas will try to turn all of the data into ints and floats. Make sure that read_csv keeps them as strings. The missing data are filled in as NaN's (Not a Number), which count as floats. We'll fix that in the next function.

2. get_series: This function takes a sun DataFrame as created by the previous function and returns two Series, one for sunrise data, one for sunset data. The both have the same format. Here is a screenshot of the sunrise Series:

This index is now datetime objects, the NaN values are gone, and the data are therefore all strings. I suggest concatenating the appropriate columns from the sun frame into a sunrise Series, the same for a sunset Series, deleting the NaN's, and replacing the Index objects for both Series with the appropriate sequence of timestamps. Functions that might be helpful: pd.concat, pd.dropna, pd.date_range. ReturnthetwoSerieswiththesyntaxreturnrise,set.

3. longest_day: ThisfunctiontakessunriseandsunsetSeriesandreturnsthetimestampofthe longest day and an hour-minute string that represents the length of that day (just like the strings in theSeries). If there is more than one longest day, return the first one (earliest date). Series methods that may be helpful: astype, idxmax. I suggest converting the hour-minute strings in the twoSeries into minutes (ints). Then you can subtract sunrise from sunset to get the length of the day in minutes. When you get your functions running, use them to determine the date of the longest day in 2018.

4. sunrise_dif: ThisfunctiontakesasunriseSeriesandatimestamp. Itreturnsthedifferencein minutes between the sunrise time 90 days before the timestamp and 90 days after. We could return the absolute value, but we would lose some information, so we won't. Calculate it this way: sunrise 90 before sunrise 90 after. Run this code passing in the timestamp as calculated by the previous function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

Is how things are said consistent with what is said?

Answered: 1 week ago

Question

Do you currently have a team agreement?

Answered: 1 week ago