Multi-index concatenation error pandas dataframes (categorical)

L is a list of data frames with multiple indices in rows.

pd.concat(L,axis=1) 

I get the following error (from the Categorical constructor in categorical.py ):

TypeError: "values" is not ordered, explicitly specify the order of the categories by passing the category argument.

It clearly has to do with the values ​​in my data framework, as I can get it to work if I somehow restrict the data.

eg. all these works

 a=pd.concat(L[0:6],axis=1) b=pd.concat(L[6:11],axis=1) c=pd.concat(L[3:9],axis=1) 

but

 d=pd.concat(L[0:11],axis=1) 

not executed.

 pd.concat([x.iloc[0:1000,:] for x in L[0:11]],axis=1) 

also works. I went through the edges in which it broke, and for life I can not see anything that could be offensive in these ranks. Anyone have any ideas on what I should look for?

+5
source share
1 answer

I ran into the same error:

TypeError: "values" is not ordered, explicitly specify the order of the categories by passing the category argument.

However, there is little material around it. See what the error log says a bit above. I have:

TypeError: unorderable types: range () <Range ()

When processing the above exception, another exception occurred:

The key was 'range () <range (), because I had a previous problem here with the Pandas interpretation of' (1,2) 'or' (30,31) 'not as a string, but as' range (1,3) 'or' range (30.32) ', respectively. Very annoying as dtypes is still an object.

I had to change the contents of the column to lists and / or delete the column "range (x, y)".

Hope this helps or anyone else who is facing this issue. Hooray!

0
source

Source: https://habr.com/ru/post/1258681/


All Articles