skrtel1503
skrtel1503

Reputation: 21

ValueError: Length mismatch: Expected axis has 9994 elements, new values have 1 elements

I got an error with the following function:

def function(df,column,value): 
    df=df.set_index([column]).filter(regex=value, axis=0)
    return df

function(df,[column],'xyz')

Error:

ValueError: Length mismatch: Expected axis has 9994 elements, new values have 1 elements

NOTE: I have to fix the function. I cant use a different solution.

Upvotes: 0

Views: 658

Answers (1)

hasanyaman
hasanyaman

Reputation: 328

Try

df.set_index(column)

Because right now you are passing second argument as a list.

Upvotes: 0

Related Questions