parade.type package¶
Submodules¶
parade.type.dateparser module¶
-
parade.type.dateparser.create_date_formats(day_first=True)¶ generate combinations of time and date formats with different delimeters
-
parade.type.dateparser.is_date(value)¶
parade.type.stdtypes module¶
-
class
parade.type.stdtypes.ArrayType(item_type)¶
-
class
parade.type.stdtypes.BoolType(true_values=None, false_values=None)¶ Bases:
parade.type.stdtypes.CellTypeA boolean field. Matches true/false, yes/no and 0/1 by default, but a custom set of values can be optionally provided.
-
cast(value)¶
-
false_values= (u'no', u'false')¶
-
guessing_weight= 7¶
-
result_type¶ alias of
__builtin__.bool
-
true_values= (u'yes', u'true')¶
-
-
class
parade.type.stdtypes.CellType¶ Bases:
objectA cell type maintains information about the format of the cell, providing methods to check if a type is applicable to a given value and to convert a value to the type.
-
cast(value)¶ Convert the value to the type. This may throw a quasi-random exception if conversion fails. :param value:
-
guessing_weight= 1¶
-
classmethod
instances()¶
-
result_type= None¶
-
test(value)¶ Test if the value is of the given type. The default implementation calls
castand checks if that throws an exception. True or False :param value:
-
-
class
parade.type.stdtypes.DateType(only_date=False, format=u'%Y-%m-%d %H:%M:%S')¶ Bases:
parade.type.stdtypes.CellTypeThe date type is special in that it also includes a specific date format that is used to parse the date, additionally to the basic type information.
-
cast(value)¶
-
formats= ['%d.%m.%y%H:%M:%S', '%Y-%m-%dT%H:%M:%S%Z', '%Y/%m/%d%H:%M:%S', '%d/%b/%Y%H:%M:%S', '%d %B %YT%H:%M%Z', '%d/%m/%Y', '%Y.%m.%d', '%d/%m/%yT%H:%M:%S%Z', '%d-%B-%Y', '%d.%b.%Y', '%d/%b/%YT%H:%M%Z', '%d.%B.%Y%H:%M:%S%Z', '%d/%B/%Y %H:%M:%S', '%d-%m-%yT%H:%M:%S%Z', '%d-%m-%Y%H:%M:%S%Z', '%d/%m/%YT%H:%M:%S', '%d %m %y %H:%M:%S', '%Y-%m-%d%H:%M%Z', '%d/%m/%y %H:%M%Z', '%d/%b/%Y %H:%M:%S%Z', '%d.%m.%Y%H:%M%Z',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%B.%YT%H:%M:%S%Z', '%d-%b-%YT%H:%M%Z', '%d/%m/%y%H:%M%Z', '%d-%B-%Y %H:%M:%S', '%Y.%m.%dT%H:%M%Z', '%d/%m/%Y %H:%M%Z', '%d.%b.%YT%H:%M:%S%Z', '%d %m %YT%H:%M%Z', '%d/%m/%YT%H:%M%Z', '%d %B %Y %H:%M%Z', '%d.%m.%y %H:%M%Z', '%d %m %Y %H:%M:%S', '%Y/%m/%d', '%d/%B/%YT%H:%M%Z']¶
-
guessing_weight= 3¶
-
classmethod
instances()¶
-
result_type¶ alias of
datetime.datetime
-
test(value)¶
-
-
class
parade.type.stdtypes.DateUtilType¶ Bases:
parade.type.stdtypes.CellTypeThe date util type uses the dateutil library to parse the dates. The advantage of this type over DateType is the speed and better date detection. However, it does not offer format detection. Do not use this together with the DateType
-
cast(value)¶
-
guessing_weight= 3¶
-
result_type¶ alias of
datetime.datetime
-
-
class
parade.type.stdtypes.DecimalType¶ Bases:
parade.type.stdtypes.CellTypeDecimal number,
decimal.Decimalor float numbers.-
cast(value)¶
-
guessing_weight= 4¶
-
result_type¶ alias of
decimal.Decimal
-
-
class
parade.type.stdtypes.FloatType¶ Bases:
parade.type.stdtypes.DecimalTypeFloatType is deprecated
-
class
parade.type.stdtypes.IntegerType(length=11)¶ Bases:
parade.type.stdtypes.CellTypeAn integer field.
-
cast(value)¶
-
guessing_weight= 6¶
-
result_type¶ alias of
__builtin__.int
-
-
class
parade.type.stdtypes.StringType(max_len=0)¶ Bases:
parade.type.stdtypes.CellTypeA string or other unconverted type.
-
cast(value)¶
-
result_type¶ alias of
__builtin__.str
-
Module contents¶
-
parade.type.sqltype_to_stdtype(sqltype)¶
-
parade.type.stdtype_to_sqltype(stdtype)¶
-
parade.type.str_to_sqltype(expr)¶
-
parade.type.str_to_stdtype(expr)¶
-
parade.type.type_guess(df, strict=False)¶ The type guesser aggregates the number of successful conversions of each column to each type, weights them by a fixed type priority and select the most probable type for each column based on that figure. It returns a list of
CellType. Empty cells are ignored. Strict means that a type will not be guessed if parsing fails for a single cell in the column. :param df: :param strict: