Features.fetch_codes

Features.fetch_codes(update=False, dump_dir=None, verbose=False)

Fetch codes of infrastructure features.

Including:

Parameters
  • update (bool) – whether to do an update check (for the package data), defaults to False

  • dump_dir (str or None) – name of a folder where the pickle file is to be saved, defaults to None

  • verbose (bool or int) – whether to print relevant information in console, defaults to False

Returns

data of features codes and date of when the data was last updated

Return type

dict

Examples:

>>> from pyrcs.other_assets import Features  # from pyrcs import Features

>>> feats = Features()

>>> feats_codes = feats.fetch_codes()
>>> type(feats_codes)
dict
>>> list(feats_codes.keys())
['Features', 'Last updated date']

>>> feats.KEY
'Features'

>>> feats_codes_dat = feats_codes[feats.KEY]
>>> type(feats_codes_dat)
dict
>>> list(feats_codes_dat.keys())
['Buzzer codes', 'HABD and WILD', 'Telegraphic codes', 'Water troughs']

>>> water_troughs_locations = feats_codes_dat[feats.KEY_TO_TROUGH]
>>> type(water_troughs_locations)
pandas.core.frame.DataFrame
>>> water_troughs_locations.head()
    ELR  ... Length (Yard)
0   BEI  ...           NaN
1   BHL  ...    620.000000
2  CGJ2  ...      0.666667
3  CGJ6  ...    561.000000
4  CGJ6  ...    560.000000
[5 rows x 6 columns]

>>> hw_codes_dat = feats_codes_dat[feats.KEY_TO_HABD_WILD]
>>> type(hw_codes_dat)
dict
>>> list(hw_codes_dat.keys())
['HABD', 'WILD']
>>> habd_dat = hw_codes_dat['HABD']
>>> type(habd_dat)
pandas.core.frame.DataFrame
>>> habd_dat.head()
    ELR  ...                                              Notes
0  BAG2  ...
1  BAG2  ...  installed 29 September 1997, later moved to 74...
2  BAG2  ...                             previously at 74m 51ch
3  BAG2  ...                          removed 29 September 1997
4  BAG2  ...           present in 1969, later moved to 89m 00ch
[5 rows x 5 columns]
>>> wild_dat = hw_codes_dat['WILD']
>>> type(wild_dat)
pandas.core.frame.DataFrame
>>> wild_dat.head()
    ELR  ...                                              Notes
0  AYR3  ...
1  BAG2  ...
2  BML1  ...
3  BML1  ...
4  CGJ3  ...  moved to 183m 68ch from 8 September 2018 / mov...
[5 rows x 5 columns]