File size: 1,083 Bytes
84568a9
 
 
 
1835c3d
84568a9
 
 
 
 
 
 
3881c30
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
norm_params = {
    'LAT': {'min_val': -66.817333, 'max_val': 51.055833},
    'LON': {'min_val': -178.116667, 'max_val': 171.358333},
    'ALTI': {'min_val': 0.0, 'max_val': 3845.0},
    'AAAAMMJJHH': {'min_val': 1777010107, 'max_val': 2555123112},
    'ANNEE': {'min_val': 1777, 'max_val': 2024},
    'MOIS': {'min_val': 1, 'max_val': 12},
    'JOUR': {'min_val': 1, 'max_val': 31},
    'HEURE': {'min_val': 0, 'max_val': 23},
}

def normalize_column(column, min_val, max_val):
    """Normalize pandas Series from [min_val, max_val] to [0, 1]."""
    return (column.astype('float64') - min_val) / (max_val - min_val)

def extract_date_parts(chunk):
    chunk['AAAAMMJJHH'] = chunk['AAAAMMJJHH'].astype(int)
    chunk['ANNEE'] = (chunk['AAAAMMJJHH'] // 1000000).astype(int)
    chunk['MOIS'] = ((chunk['AAAAMMJJHH'] // 10000) % 100).astype(int)
    chunk['JOUR'] = ((chunk['AAAAMMJJHH'] // 100) % 100).astype(int)
    chunk['HEURE'] = (chunk['AAAAMMJJHH'] % 100).astype(int)
    chunk = chunk[(chunk['ANNEE'] <= 2024) & (chunk['MOIS'] <= 12) & (chunk['JOUR'] <= 31)]
    return chunk