Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my dataframe: Hungry Tell Number Age 0 1 Yes 3 16 1 1 Yes 6 16 2 0 No 9 18 3 1

Here is my dataframe:

 Hungry Tell Number Age 0 1 Yes 3 16 1 1 Yes 6 16 2 0 No 9 18 3 1 Yes 4 24 4 0 Yes 7 27 5 0 No 8 24 6 1 Yes 15 35 7 1 Yes 8 38 8 0 No 6 39 9 0 Yes 13 35 # Creating the dictionary dic = {'Hungry': [1,1,0,1,0,0,1,1,0,0], 'Tell': ['Yes', 'Yes', 'No', 'Yes','Yes', 'No','Yes', 'Yes','No', 'Yes'], 'Class': [3,1,3,2,3,1,1,2,3,3], 'Age': [16,16,18,24,27,24,35,38,39,35]} # Creating the dataframe df = pd.DataFrame(dic) 

I want a function that can conduct an independent-samples t-test on any two selections of data from the data frame. It checks if the selected columns are numeric first.

Here is what I started with:

It takes three arguments. First selection of data, second selection of data and the dataframe.

import pandas as pd from scipy import stats def ttestind (sel1,sel2,dataframe): if dataframe[str(sel1)].isNumeric()==true and dataframe[str(sel2)].isNumeric()==true: print(stats.ttest_ind(dataframe[str(first)],dataframe[str(second)])) 

Please help

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions