Archive/Old Shell Version/camp_records.py
def _normalize(self):
        "Take each of the camper field and move them so that we end up with"
        "a row for each camper."

        # Extract each camper.
        campers = [self._df[GROUP_FIELDS+camper_fields(
            " (Camper {})".format(i))] for i in range(1, MAX_NUM_OF_CAMPERS+1)]
        for camper in campers:
            camper.columns = [GROUP_FIELDS+camper_fields('')]

        norm = pd.concat(campers)
        norm.reset_index(drop=True, inplace=True)

        def conv(x):
            try:
                return int(x)
            except:
                return 0
        norm[AGE.format('')] = norm[AGE.format('')].map(conv)

        # Create booking reference column.
        def create_ref(row):
            (d, mo, y) = row[REF].split(' ')[0].split('/')
            (h, mi, s) = row[REF].split(' ')[1].split(':')
            return "{}/{}{}{}{}".format(row[FAMILY], d, mo, h, mi)

        norm[I_REF] = [create_ref(row) for index, row
                       in norm.iterrows()]

        # remove rows where there is no camper
        norm = norm[~((norm[NAME.format('')] == '') &
                      (norm[SURNAME.format('')] == ''))]

        return norm
Take each of the camper field and move them so that we end up with
Take each of the camper field and move them so that we end up with
Take each of the camper field and move them so that we end up with
def _normalize(self):
        campers = [self._df[GROUP_FIELDS+camper_fields(
            " (Camper {})".format(i))] for i in range(1, MAX_NUM_OF_CAMPERS+1)]
        for camper in campers:
            camper.columns = [GROUP_FIELDS+camper_fields('')]
        norm = pd.concat(campers)
        norm.reset_index(drop=True, inplace=True)
        def conv(x):
            try:
                return int(x)
            except:
                return 0
        norm[AGE.format('')] = norm[AGE.format('')].map(conv)
        def create_ref(row):
            (d, mo, y) = row[REF].split(' ')[0].split('/')
            (h, mi, s) = row[REF].split(' ')[1].split(':')
            return "{}/{}{}{}{}".format(row[FAMILY], d, mo, h, mi)
        norm[I_REF] = [create_ref(row) for index, row
                       in norm.iterrows()]
        norm = norm[~((norm[NAME.format('')] == '') &
                      (norm[SURNAME.format('')] == ''))]
        return norm
def _normalize ( self ) : "a row for each camper." campers = [ self . _df [ GROUP_FIELDS + camper_fields ( " (Camper {})" . format ( i ) ) ] for i in range ( 1 , MAX_NUM_OF_CAMPERS + 1 ) ] for camper in campers : camper . columns = [ GROUP_FIELDS + camper_fields ( '' ) ] norm = pd . concat ( campers ) norm . reset_index ( drop = True , inplace = True ) def conv ( x ) : try : return int ( x ) except : return 0 norm [ AGE . format ( '' ) ] = norm [ AGE . format ( '' ) ] . map ( conv ) def create_ref ( row ) : ( d , mo , y ) = row [ REF ] . split ( ' ' ) [ 0 ] . split ( '/' ) ( h , mi , s ) = row [ REF ] . split ( ' ' ) [ 1 ] . split ( ':' ) return "{}/{}{}{}{}" . format ( row [ FAMILY ] , d , mo , h , mi ) norm [ I_REF ] = [ create_ref ( row ) for index , row in norm . iterrows ( ) ] norm = norm [ ~ ( ( norm [ NAME . format ( '' ) ] == '' ) & ( norm [ SURNAME . format ( '' ) ] == '' ) ) ] return norm
Take each of the camper field and move them so that we end up with
Take each of the camper field and move them so that we end up with
"Take each of the camper field and move them so that we end up with" "a row for each camper." # Extract each camper. # Create booking reference column. # remove rows where there is no camper
self