Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 598a45cd authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

Fixed bugs in type and sort tables

parent a85ededb
No related branches found
No related tags found
No related merge requests found
......@@ -21,18 +21,15 @@ def typeTableColumns( df ):
df['inc'] = df['inc'].astype(float)
if 'revisionModality' in df.columns or 'revisionModality' in df.index.names:
df['revisionModality'] = pd.Categorical(df['revisionModality'], ["nothing", "delete", "replace", "refine", "add", "addjoin", "refadd"])
# JE: Why do I have ops! (mind the column!)
if 'ops' in df.columns:
df['ops'] = pd.Categorical(df['ops'], ["nothing", "delete", "replace", "refine", "add", "addjoin", "refadd"])
if 'str' in df.columns:
df['str'] = pd.Categorical(df['str'], ['_',"strgen", "strspc", "strrdm"])
if 'strenghen' in df.index.names:
df['strenthen'] = pd.Categorical(df['strenghen'], ['_',"strgen", "strspc", "strrdm"])
# ??
if 'generative' in df.columns or 'generative' in df.index.names:
df['generative'] = pd.Categorical(df['generative'], ['_NOT_','_','1'])
if 'expandAlignments' in df.columns or 'expandAlignments' in df.index.names:
df['expandAlignments'] = pd.Categorical(df['expandAlignments'], ['_','_NOT_','memory','clever'])
#if 'generative' in df.columns or 'generative' in df.index.names:
# df['generative'] = pd.Categorical(df['generative'], ['_NOT_','_','1'])
#if 'expandAlignments' in df.columns or 'expandAlignments' in df.index.names:
# df['expandAlignments'] = pd.Categorical(df['expandAlignments'], ['_','_NOT_','memory','clever'])
# Better keep these as strings...
#if 'immediateRatio' in df.columns or 'immediateRatio' in df.index.names:
# df.replace({'immediateRatio':{'_':'0'}}, inplace = True)
......@@ -80,6 +77,7 @@ def orderRenameTable( df, indexDict ):
indexNames = []
colArray = []
colDict = []
sortIndex = []
nblevels = df.index.nlevels
for index, name in indexDict.items():
if (nblevels > 1) and index in df.index.names:
......@@ -89,6 +87,8 @@ def orderRenameTable( df, indexDict ):
if index in df.columns:
colArray += [index]
colDict += [(index, name)]
if name in ['Relaxation','Generation','Expansion','Strenghening','Operator']
sortIndex += [name]
# Reorder (levels and columns)
if (nblevels > 1):
df = df.reorder_levels( indexSelect )
......@@ -98,7 +98,7 @@ def orderRenameTable( df, indexDict ):
df.index.names = indexNames
df.rename( dict( colDict ), axis='columns', inplace=True )
# Sort the rows (by index column order)
df = df.sort_values( by = indexNames )
df = df.sort_values( by = sortIndex )
return df
### FORMATTING
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment