Remove unused town numbers in statistics
This commit is contained in:
parent
8eeea264d0
commit
8d00290dd2
1 changed files with 7 additions and 1 deletions
|
@ -82,6 +82,12 @@ def import_towns_csv(raw_file):
|
||||||
return towns.loc[towns['TYPECOM'] == 'COM', ['COM','NCC', 'LIBELLE', 'DEP']]
|
return towns.loc[towns['TYPECOM'] == 'COM', ['COM','NCC', 'LIBELLE', 'DEP']]
|
||||||
|
|
||||||
|
|
||||||
|
def stats_convert(codegeo):
|
||||||
|
if len(codegeo) == 4:
|
||||||
|
return 0 + codegeo
|
||||||
|
if len(codegeo) == 6:
|
||||||
|
return codegeo[1:]
|
||||||
|
return codegeo
|
||||||
|
|
||||||
def import_statistics_csv(raw_file):
|
def import_statistics_csv(raw_file):
|
||||||
"""
|
"""
|
||||||
|
@ -89,7 +95,6 @@ def import_statistics_csv(raw_file):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.info('import town from {}'.format(raw_file))
|
logger.info('import town from {}'.format(raw_file))
|
||||||
stats_convert= lambda x: x if len(str(x)) == 5 else f'0{x}'
|
|
||||||
stats = pd.read_csv(raw_file,
|
stats = pd.read_csv(raw_file,
|
||||||
usecols=["CODGEO","SUPERF","P18_POP","P13_POP","P08_POP","D99_POP",
|
usecols=["CODGEO","SUPERF","P18_POP","P13_POP","P08_POP","D99_POP",
|
||||||
"NAIS1318","NAIS0813","NAIS9908","NAIS9099","NAIS8290","DECE1318",
|
"NAIS1318","NAIS0813","NAIS9908","NAIS9099","NAIS8290","DECE1318",
|
||||||
|
@ -201,6 +206,7 @@ if __name__ == '__main__':
|
||||||
logger.critical('can\'t find source file for statistics')
|
logger.critical('can\'t find source file for statistics')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
statistics = import_statistics_csv(args.source + '/' + args.statistics)
|
statistics = import_statistics_csv(args.source + '/' + args.statistics)
|
||||||
|
statistics = statistics[statistics['CODGEO'].isin(towns['COM'])]
|
||||||
t.stop()
|
t.stop()
|
||||||
logger.debug(statistics)
|
logger.debug(statistics)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue