I found this thread Ignore python multiple return value but I still don't understand how it would be possible to only obtain p-value from a t-test. I'm trying to express just the p-values in a vector and I'm really struggling. I tried the fun()[1]etc method but it returns an empty index.
My code looks like this:
# Statistical analysis: unpaired t-test
import scipy
from scipy import stats
# Sorting for dosage
drug_1_1 = table.iloc[:,1][(table['Dose drug 1'] == 1)]
drug_2_1 = table.iloc[:,3][(table['Dose drug 2'] == 1)]
drug_1_2 = table.iloc[:,1][(table['Dose drug 1'] == 2)]
drug_2_2 = table.iloc[:,3][(table['Dose drug 2'] == 2)]
drug_1_3 = table.iloc[:,1][(table['Dose drug 1'] == 3)]
drug_2_3 = table.iloc[:,3][(table['Dose drug 2'] == 3)]
drug_1_4 = table.iloc[:,1][(table['Dose drug 1'] == 4)]
drug_2_4 = table.iloc[:,3][(table['Dose drug 2'] == 4)]
drug_1_5 = table.iloc[:,1][(table['Dose drug 1'] == 5)]
drug_2_5 = table.iloc[:,3][(table['Dose drug 2'] == 5)]
drug_1_6 = table.iloc[:,1][(table['Dose drug 1'] == 6)]
drug_2_6 = table.iloc[:,3][(table['Dose drug 2'] == 6)]
drug_1_7 = table.iloc[:,1][(table['Dose drug 1'] == 7)]
drug_2_7 = table.iloc[:,3][(table['Dose drug 2'] == 7)]
drug_1_8 = table.iloc[:,1][(table['Dose drug 1'] == 8)]
drug_2_8 = table.iloc[:,3][(table['Dose drug 2'] == 8)]
# Expessing p-values in vector
P_values = pd.DataFrame()
P_values['1'] = stats.ttest_ind(drug_1_1,drug_2_1)[1]
P_values['2'] = stats.ttest_ind(drug_1_2,drug_2_2)[1]
P_values['3'] = stats.ttest_ind(drug_1_3,drug_2_3)[1]
P_values['4'] = stats.ttest_ind(drug_1_4,drug_2_4)[1]
P_values['5'] = stats.ttest_ind(drug_1_5,drug_2_5)[1]
P_values['6'] = stats.ttest_ind(drug_1_6,drug_2_6)[1]
P_values['7'] = stats.ttest_ind(drug_1_7,drug_2_7)[1]
P_values['8'] = stats.ttest_ind(drug_1_8,drug_2_8)[1]
P_values.index.names = ['Dose']
print(P_values)
Which returns:
Empty DataFrame
Columns: [1, 2, 3, 4, 5, 6, 7, 8]
Index: []
Which stragenly seems to work if it's not played in the first line, but it returns the same value for both 0 and 1 in all other lines like so: https://imgur.com/a/9H7YXL7
Am I writing something wrong?