@@ -221,8 +221,6 @@ def validate_flatfile_dataframe(
221221 xp_dtype = extra_dtypes [col ]
222222 else :
223223 xp_dtype = column_dtype (col )
224- if xp_dtype == ColumnDtype .category :
225- xp_dtype = column_categorical_dtype (col )
226224
227225 if xp_dtype is None :
228226 continue
@@ -510,30 +508,15 @@ def column_help(column: str) -> str:
510508 return _load_flatfile_columns_properties ()[column ].get ('help' , "" )
511509
512510
513- def column_dtype (column : str ) -> Union [ColumnDtype , None ]:
511+ def column_dtype (column : str ) -> Union [ColumnDtype , pd . CategoricalDtype , None ]:
514512 """
515- Return the data type of the given column name, as `ColumnDtype` Enum item,
516- or None if the column has no known data type. If the return value is
517- `ColumnDtype.category`, get more info via `get_categorical_dtype(column)`.
513+ Return the data type of the given column name, as None (no data type set),
514+ `ColumnDtype` Enum item, or pands `CategoricalDtype` object (in this case
515+ `column_dtype(...).categories` will list the possible values that the column can
516+ take). As such `ColumnDtype.category` is never returned.
518517 If `column` is 'SA(<period>)', it will default to 'SA'
519518 """
520- dtype = _column_dtype (column )
521- if isinstance (dtype , pd .CategoricalDtype ):
522- return ColumnDtype .category
523- return dtype
524-
525-
526- def column_categorical_dtype (column : str ) -> Union [pd .CategoricalDtype , None ]:
527- """
528- Return the pandas CategoricalDtype, a data type for categorical data, for
529- the given column. To get the possible categories, use the `.categories` attribute
530- of the returned object. Return None if the column data type is not categorical.
531- If `column` is 'SA(<period>)', it will default to 'SA'
532- """
533- dtype = _column_dtype (column )
534- if isinstance (dtype , pd .CategoricalDtype ):
535- return dtype
536- return None
519+ return _load_flatfile_columns_properties ()[column ].get ('dtype' , None )
537520
538521
539522def _column_dtype (column : str ) -> Union [pd .CategoricalDtype , ColumnDtype , None ]:
@@ -759,8 +742,10 @@ def valid_expr_sequence(tok_num1: int, tok_val1: str, tok_num2: int, tok_val2: s
759742 elif tok_num2 == NEWLINE :
760743 return tok_num1 in {NUMBER , NAME , STRING } or tok_val1 == ')'
761744 elif (tok_num1 , tok_num2 ) == (OP , OP ):
762- return (tok_val1 + tok_val2 in
763- {'(~' , '~(' , '((' , '~~' , '))' , '&(' , '|(' , ')|' , ')&' })
745+ return (
746+ tok_val1 + tok_val2 in
747+ {'(~' , '~(' , '((' , '~~' , '))' , '&(' , '|(' , ')|' , ')&' }
748+ )
764749 elif (tok_num1 , tok_num2 ) == (NAME , OP ):
765750 return tok_val2 in {'==' , '!=' , '<' , '<=' , '>' , '>=' , ')' , '+' , '-' , '*' , '/' }
766751 elif (tok_num1 , tok_num2 ) == (OP , NAME ):
0 commit comments