spaces#

class pdcleaner.detection.strings.spaces(obj, detector=None, side='both')[source]#

Bases: _ObjectTypeSeriesDetector

Detect elements whith extra spaces before and/or after the value.

Intended to be used by the detect method with the keyword ‘spaces’

>>> series.cleaner.detect.spaces(...)
>>> series.cleaner.detect('spaces',...)

This detection method flags elements as potential errors wherever they contain an extra space at begininng or at the end.

Parameters:

side ({'leading', 'trailing', 'both'} (Default = 'both')) – The side where extraspaces will be detected

Raises:

ValueError – when unknown value is given to side parameter

Note

NA values are not treated as errors.

Examples

>>> series = pd.Series(['Paris','Paris ',' Lille', ' Lille ', 'Troyes'])
>>> detector = series.cleaner.detect.spaces(side='leading')
>>> print(detector.is_error())
0    False
1    False
2     True
3     True
4    False
dtype: bool
>>> detector = series.cleaner.detect.spaces(side='trailing')
>>> print(detector.is_error())
0    False
1     True
2    False
3     True
4    False
dtype: bool
>>> detector = series.cleaner.detect.spaces(side='both')
>>> print(detector.is_error())
0    False
1     True
2     True
3     True
4    False
dtype: bool

Attributes Summary

index

Indices of the rows detected as errors

n_errors

Number of rows detected as errors

name

obj

The object (Series or DataFrame) containing the data to which the detection is applied

side

Side to check the presence of spaces

Methods Summary

detected()

Series or DataFrame containing only the detected errors

has_errors()

Returns True if any error has been detected, False otherwise

is_error()

Return a boolean same-sized object indicating if the values are flagged as errors

not_error()

Return a boolean same-sized object indicating if the values are NOT flagged as errors

report()

prints a detection report

valid()

Series or DataFrame containing only the valid values

Attributes Documentation

index#

Indices of the rows detected as errors

n_errors#

Number of rows detected as errors

name = 'spaces'#
obj#

The object (Series or DataFrame) containing the data to which the detection is applied

side#

Side to check the presence of spaces

Methods Documentation

detected()#

Series or DataFrame containing only the detected errors

has_errors() bool#

Returns True if any error has been detected, False otherwise

is_error() Series#

Return a boolean same-sized object indicating if the values are flagged as errors

not_error() Series#

Return a boolean same-sized object indicating if the values are NOT flagged as errors

report()#

prints a detection report

valid()#

Series or DataFrame containing only the valid values