Type inference¶
- class agate.TypeTester(force={}, limit=None, types=None, null_values=('', 'na', 'n/a', 'none', 'null', '.'))¶
- Bases: - object- Control how data types are inferred for columns in a given set of data. - This class is used by passing it to the - column_typesargument of the- Tableconstructor, or the same argument for any other method that create a- Table- Type inference can be a slow process. To limit the number of rows of data to be tested, pass the - limitargument. Note that may cause errors if your data contains different types of values after the specified number of rows.- By default, data types will be tested against each column in this order: - Individual types may be specified using the - forceargument. The type order by be changed, or entire types disabled, by using the- typesargument. Beware that changing the order of the types may cause unexpected behavior.- Parameters:
- force – A dictionary where each key is a column name and each value is a - DataTypeinstance that overrides inference.
- limit – An optional limit on how many rows to evaluate before selecting the most likely type. Note that applying a limit may mean errors arise when the data is cast–if the guess is proved incorrect in further rows of data. 
- types – A sequence of possible types to test against. This be used to specify what data formats you want to test against. For instance, you may want to exclude - TimeDeltafrom testing. It can also be used to pass options such as- localeto- Numberor- cast_nullsto- Text. Take care in specifying the order of the list. It is the order they are tested in.- Textshould always be last.
- null_values – If - typesis- None, a sequence of values which should be cast to- Nonewhen encountered by the default data types.
 
 - run(rows, column_names)¶
- Apply type inference to the provided data and return an array of column types. - Parameters:
- rows – The data as a sequence of any sequences: tuples, lists, etc.