-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
38 lines (30 loc) · 1.46 KB
/
utils.py
File metadata and controls
38 lines (30 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pandas as pd
import configparser
from pathlib import Path
import os.path as op
from datetime import datetime, timedelta
import time
from uuid import uuid4
def process_codecarbon_file(filename, process_id, task_name, postal_code)-> pd.DataFrame:
"""
Read file and remove longitude and latitude from file.
"""
data = pd.read_csv(filename, sep=',', header=0)
data = data[['run_id', 'project_name','timestamp', 'duration', 'emissions',
'emissions_rate', 'cpu_power', 'gpu_power', 'ram_power', 'cpu_energy',
'gpu_energy', 'ram_energy', 'energy_consumed', 'country_name',
'country_iso_code', 'region', 'cloud_provider', 'cloud_region', 'os',
'python_version', 'codecarbon_version', 'cpu_count', 'cpu_model',
'gpu_count', 'gpu_model', 'ram_total_size',
'tracking_mode', 'on_cloud', 'longitude', 'latitude']]
data.columns = ['task_hash','task_name','start_time', 'duration', 'emissions',
'emissions_rate', 'cpu_power', 'gpu_power', 'ram_power', 'cpu_energy',
'gpu_energy', 'ram_energy', 'energy_consumed', 'country_name',
'country_iso_code', 'region', 'cloud_provider', 'cloud_region', 'os',
'python_version', 'codecarbon_version', 'cpu_count', 'cpu_model',
'gpu_count', 'gpu_model', 'ram_total_size',
'tracking_mode', 'on_cloud', 'longitude', 'latitude']
data['postal_code'] = postal_code
data['task_hash'] = process_id
data['task_name'] = task_name
return data