I want to write a code (with few lines) that runs t-test on Product and Purchase_cost,warranty_years and service_cost at the same time.
# dataset
import pandas as pd
from scipy.stats import ttest_ind
data = {'Product': ['laptop', 'printer','printer','printer','laptop','printer','laptop','laptop','printer','printer'],
'Purchase_cost': [120.09, 150.45, 300.12, 450.11, 200.55,175.89,124.12,113.12,143.33,375.65],
'Warranty_years':[3,2,2,1,4,1,2,3,1,2],
'service_cost': [5,5,10,4,7,10,4,6,12,3]
}
df = pd.DataFrame(data)
print(df)
code attempt for Product & Purchase_cost. I want to run t-test for Product & warranty_years and Product & service cost
#define samples
group1 = df[df['Product']=='laptop']
group2 = df[df['Product']=='printer']
#perform independent two sample t-test
ttest_ind(group1['Purchase_cost'], group2['Purchase_cost'])
service_costandwarranty_years. ignore parallelization and optimization