Question

In: Computer Science

Consider the file “PatientTemperature_CSV.csv” given to you representing patient body temperatures at a hospital on a...

  1. Consider the file “PatientTemperature_CSV.csv” given to you representing patient body temperatures at a hospital on a particular day. The data is organized into two columns: patient temperature and patient age. Using code snippets available from the class lecture material or otherwise, perform the following tasks with this data in python: [80 points]
    1. Read the data into Python
    2. Determine the mean, mode, median, variance, and standard deviation for the patient temperatures.
    3. Determine the mean, median, variance, and standard deviation for the patient ages.
    1. Determine the probability that a patient would have a body temperature greater than or equal to 97 F and lesser than or equal to 98 F.
    2. Plot a histogram of the temperature data. Please include a title and proper axes labels.

(Note: For parts b, c and d, your code must clearly print out the required quantities when executed. The display on screen must clearly say what quantity is being printed (eg: “The mean is: 3.45”, etc.).

The included spreadsheet

https://1drv.ms/x/s!ApVa8VAkzZo-aW5eXs8WmFBLivw

I can also post the file in the comments if that would be helpful.

Solutions

Expert Solution

The columns should have had a heading depicting the patient's age and patient's temperature so I have added just one column which would act as a heading for the columns. Also, the code which I have written considers that the spreadsheet (in excel format) and the python file are in the same folder. If you want to store them in separate forlders then you need to specify complete addresses.

Here is the code to do so,


please note that the mode from scipy stats returns a tuple containing the mode and the count, so to get the mode we need to access the mode parameter of the tuple.

The sample output is:

if the answer helped, please upvote and incase you have any doubts post a comment i will surely help.

Code:

# using the pandas library we will do all the reading of data
import pandas as pd
import numpy as np
from scipy import stats as st
import matplotlib.pyplot as plt

# read the excel file and seperate the two columns into seperate lists
df = pd.read_excel (r'Book.xlsx')
temp = np.array(df['Temperature'].tolist())
age = np.array(df['Age'].tolist())

# use the mean, median variance and standard deviation module from numpy
# and use the mode module from scipy.stats to caculate the parameters for
# temperature and age
meanAge = np.mean(age)
modeAge = st.mode(age)
medianAge = np.median(age)
varianceAge = np.var(age)
deviationAge = np.std(age)

meanTemperature = np.mean(temp)
modeTemperature = st.mode(temp)
medianTemperature = np.median(temp)
varianceTemperature = np.var(temp)
deviationTemperature = np.std(temp)

# to calculate the probablity, find all temperatures in the suitable range
# and divide it by the total number of temperatures, that gives the probablity
count = 0
for item in temp:
if item >=97 and item <=98:
count = count + 1
probablity = count/len(temp)

# plot a histogram using matplotlib
plt.hist(temp, bins = 40)
plt.ylabel('No of times')
plt.xlabel('Temperature')
plt.title('Temperature histogram')
plt.show()

# print all the data using f strings
print(f"The mean age is {meanAge} and the mean Temperature is {meanTemperature}")
print(f"The median age is {medianAge} and the median Temperature is {medianTemperature}")
print(f"The mode age is {modeAge.mode} and the mode Temperature is {modeTemperature.mode}")
print(f"The standard deviation of age is {deviationAge} and the standard deviation of Temperature is {deviationTemperature}")
print(f"The variance of age is {varianceAge} and the variance of Temperature is {varianceTemperature}")


Related Solutions

A sample of 36 body temperatures body temperatures has a mean of 98.2℉ and a standard...
A sample of 36 body temperatures body temperatures has a mean of 98.2℉ and a standard deviation of 0.92℉. Construct a 95% confidence interval estimate of the mean body temperature for adults. Interpret your results.
Java. Given an input file with each line representing a record of data and the first...
Java. Given an input file with each line representing a record of data and the first token (word) being the key that the file is sorted on, we want to load it and output the line number and record for any duplicate keys we encounter. Remember we are assuming the file is sorted by the key and we want to output to the screen the records (and line numbers) with duplicate keys. We are given a text file and have...
Consider that you want to rename all files of a given type (e.g. file extension) to...
Consider that you want to rename all files of a given type (e.g. file extension) to a different filetype. For example, you want to change the file extension of all txt files to text. Write a shell script rename.sh (3%) that: takes two options as arguments. The first argument is the filetype you want to change. The second argument is the filetype you want to change files into. check that the two arguments are actually given. If not, the script...
1. Human Body Temperature. A sample of 115 body temperatures with a mean of 98.20℉ and...
1. Human Body Temperature. A sample of 115 body temperatures with a mean of 98.20℉ and a standard deviation of 0.62℉. Use a 0.05 significance level to test the claim that the mean body temperature of the population is equal to 97.6℉, as is commonly believed. Is there sufficient evidence to conclude that the common belief wrong? 2. Smartphone Users. A Ring Central survey of 395 smartphone users showed that 158 of them said that their smartphone is the only...
Include an original free body diagram and an original extended free body diagram representing the ideal...
Include an original free body diagram and an original extended free body diagram representing the ideal disposition of the four main forces acting on an aeroplane during the five different stages of flight. Explain your diagrams and describe the effect of each of these forces in the aeroplane translation and rotation. Include the angle of attack.
A statistician measures 101 randomly selected body temperatures and finds the mean body temperature to be...
A statistician measures 101 randomly selected body temperatures and finds the mean body temperature to be 98.3 with a standard deviation of 0.61. Use a 0.01 significance level to test the claim that the mean body temperature is not 98.6 as is commonly believed. claim: H0: H1: draw a picture compute the test statistic: state whether you reject H0 or fail to rehect H0
2) Human Body Temperature. A sample of 112 body temperatures with a mean of 98.20°F and...
2) Human Body Temperature. A sample of 112 body temperatures with a mean of 98.20°F and a standard deviation of 0.62°F. Use a 0.05 significance level to test the claim that the mean body temperature of the population is equal to 99.6°F, as is commonly believed. Is there sufficient evidence to conclude that the common belief wrong?
An intramuscular medication is given at 3.00mg per kg body weight. If the patient weighs 157...
An intramuscular medication is given at 3.00mg per kg body weight. If the patient weighs 157 pounds, how much medication is needed? Show work
1. You are working in a hospital and a patient was brought in with purple rash...
1. You are working in a hospital and a patient was brought in with purple rash covering their body. You need to explain to the others that this patient has a Neisseria meningitidis blood poisoning. I. Explain the pathogenesis of the disease and what is the virulence factor? II. How does the bacterium defend its self against the immune system? III. How such a disease is to be treated and why the use of this treatment method. IV. Explain why...
You are a clinician in the psychiatric ward of the local hospital. A patient is refusing...
You are a clinician in the psychiatric ward of the local hospital. A patient is refusing medication. Before medicating against his will, the likely next step, the actiing psychiatrist has asked that a therapist meet with the individual in a last ditch effort for them to take the medication voluntarily. You are that therapist and you are given the brief note found below before entering the room to speak with the patient. How might you address Mr. Johns?   _______________________ Mr....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT