How to test independence between multiple independent categorical data and one dependent continuous data in Python? I have data with two categorical independent variables and one continuous dependent variable. I want to check for the independence between variables. What type of test will tell me whether they are independent or not? My data looks like this:
gender  time      sleep_hrs
male    day        5.5
female  day        7.40
male    night      9.30
female  night      10.5

I have four groups here:

*

*male - day

*male - night

*female - day

*female - night


The typical way to handle this problem is to run a linear regression model, where sleep_hrs is the response and gender and time are predictors. In your case, however, your predictors are categorical variables and thus performing a linear regression model boils down to performing an ANOVA test.
Since you are interested in the joint behaviour of gender and time, the two-way ANOVA is what you are looking for. I am not very familiar with python, but in R, assuming the dataset is mydata, you can proceed this way.
Run
summary(aov(sleep_hrs ~ gender * time, data = mydata))

and look at the p-value (column Pr(>F)) of the row gender:time. If the p-value is low enough, say less than $0.01$ if you choose $\alpha=0.01$, then it means there is an interaction effect. That is to say, the four groups are statistically different in terms of mean sleep_hrs.
Then look at the rows named gender and time. The associated p-value of gender tells you if males have different mean sleep_hrs with respect to females; by the same token, the p-value associated with time tells you if the two time groups have the same mean sleep_hrs.
You should also take a look at the residuals of the model to make sure they satisfy the assumptions of the ANOVA test.
