Вопрос по python – Возвращение нескольких значений из панд применяется к DataFrame

44

Error: User Rate Limit ExceededDataFrameError: User Rate Limit Exceeded

import numpy
import pandas

df = pandas.DataFrame(numpy.log2(numpy.randn(1000, 4), 
                      columns=["a", "b", "c", "d"])

df = df.dropna()

Error: User Rate Limit ExceededapplyError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

from scipy.stats import ttest_ind

def t_test_and_mean(series, first, second):
    first_group = series[first]
    second_group = series[second]
    _, pvalue = ttest_ind(first_group, second_group)

    mean_ratio = second_group.mean() / first_group.mean()

    return (pvalue, mean_ratio)

Error: User Rate Limit Exceeded

df.apply(t_test_and_mean, first=["a", "b"], second=["c", "d"], axis=1)

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded Einar
Error: User Rate Limit ExceededapplyError: User Rate Limit ExceededDataFrameError: User Rate Limit Exceededt_test_and_meanError: User Rate Limit Exceededapply. lbolla

Ваш Ответ

1   ответ
68

Error: User Rate Limit Exceeded

return pandas.Series({'pvalue': pvalue, 'mean_ratio': mean_ratio})
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededpandas.Series([pvalue, mean_ratio], index=['pvalue', 'mean_ratio'])
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Einar

Похожие вопросы