Question

How can I do these operations in python ? Given a loaded dataset: a) At the...

How can I do these operations in python ?

Given a loaded dataset:

a) At the α = 0.05 significance level, test whether the variance of rental prices differs

for private room rentals compared to entire house rentals.

b) At the α = 0.01 significance level, test whether the average price of entire house

rentals is greater than the average price of private room rentals.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Sample dataset

Part a

Part b

Python code in text

import pandas as pd
data = [['House', 20000], ['House', 25000], ['House', 22000],['Private', 5000], ['Private', 7000], ['Private', 9000]]
df = pd.DataFrame(data, columns = ['accommodation', 'Price'])
print(df)

from scipy import stats
import matplotlib.pyplot as plt
ret=stats.f_oneway(df["Price"][df["accommodation"]=="House"],df["Price"][df["accommodation"]=="Private"])
print(ret)
if ret[1]<0.05:

print("Reject the null hypothesis so accommodation types have differences in variances")

else:

print("Accept the null hypothesis so accommodation types have similar variances")

df.boxplot("Price",by="accommodation")
plt.show()

Private=df[df["accommodation"]=="Private"]
entirehouse=df[df["accommodation"]=="House"]
ret=stats.ttest_ind(Private["Price"],entirehouse["Price"])
if ret[1]<0.05:

print("Reject the null hypothesis so average price of entire house is greater")

else:

print("Accept the null hypotheses so average price of entire house isn't greater")

Add a comment
Know the answer?
Add Answer to:
How can I do these operations in python ? Given a loaded dataset: a) At the...
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
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