Filipe Ferminiano
Filipe Ferminiano

Reputation: 8791

ValueError: Shape of passed values is (1, 31), indices imply (1, 32)

I'm getting this error:

 ValueError: Shape of passed values is (1, 31), indices imply (1, 32)

In this function:

def compute_r_statistic(x):
    R_stat = np.zeros(shape=(0,0))
    x = x[np.logical_not(np.isnan(x))]
    sample = x
    for i in range(0,len(x)):
        avg = np.nanmean(sample)
        std = np.nanstd(sample)
        sample = np.fabs(sample - avg)
        **print sample[0].argmax()**
        r_i = np.max(sample)/std
        R_stat = np.append(R_stat,r_i)
        #remove biggest value
        sample = np.delete(sample, -1)
    return R_stat

in this line:

print sample[0].argmax()

How can I print the argmax?

x is a pandas dataframe like this:

>>> print x
                    0
1951-03-31        NaN
1951-06-30        NaN
1951-09-30   7.918750
1951-12-31   6.936607
1952-03-31  34.029464
1952-06-30  -4.672321
1952-09-30 -15.85625

Upvotes: 0

Views: 1467

Answers (1)

Allen Qin
Allen Qin

Reputation: 19947

Try chaning:

print sample[0].argmax()

To

print(sample.iloc[:,0].argmax())

To see if it helps?

Upvotes: 1

Related Questions