Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pandas bug after upgrade in reciepe in matchid backend upgrade #142

Merged
merged 4 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions projects/deces-dataprep/datasets/deces_src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ datasets:
compression: gzip
type: fwf
encoding: latin1
widths: [80, 1, 8, 5, 30, 30, 8, 5, 9, 1]
widths: [80, 1, 8, 5, 30, 30, 8, 5, 10]
names:
- NOM_PRENOMS
- SEXE
Expand All @@ -19,4 +19,3 @@ datasets:
- DATE_DECES
- CODE_INSEE_DECES
- NUM_DECES
- END_OF_LINE
10 changes: 7 additions & 3 deletions projects/deces-dataprep/recipes/deces_dataprep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ recipes:
dataset: deces_index
threads: !ENV ${RECIPE_THREADS}
steps:
- delete:
select: END_OF_LINE
- normalize:
select: (NOM_PRENOMS|COMMUNE_NAISSANCE|PAYS_NAISSANCE|NUM_DECES)$
- exec:
Expand All @@ -17,6 +15,11 @@ recipes:
- df['_id'] = df['UID']
- df['SOURCE'] = str(desc['source']['name'])
- df['SOURCE_LINE'] = 1+df.index
- replace:
select: NUM_DECES
regex:
- '(.{9}).*': '\1'
- '\s*$': ''
- replace:
select: SOURCE
regex:
Expand Down Expand Up @@ -93,8 +96,9 @@ recipes:
select: DATE.*NORM
format: "%Y%m%d"
- exec:
# Year = 365.25 * 24 * 60 * 60 seconds
- df['AGE_DECES'] = np.where(df['DATE_DECES'] > df['DATE_NAISSANCE'],
(df['DATE_DECES_NORM'] - df['DATE_NAISSANCE_NORM']).astype('<m8[Y]'),
((df['DATE_DECES_NORM'] - df['DATE_NAISSANCE_NORM']).astype('timedelta64[s]').astype(int) / 31557600).round().astype(int),
None)
- df['DATE_NAISSANCE_NORM'] = df['DATE_NAISSANCE_NORM'].dt.strftime('%Y%m%d')
- df['DATE_DECES_NORM'] = df['DATE_DECES_NORM'].dt.strftime('%Y%m%d')
Expand Down
Loading