Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

preprocessing.py 833 B

You have to be logged in to leave a comment. Sign In
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
  1. import numpy
  2. import pandas as pd
  3. def preprocess_data(data_path, labels_path=None):
  4. # load data and set index to city, year, weekofyear
  5. print("loading dataset...")
  6. df = pd.read_csv(data_path, index_col=[0, 1, 2])
  7. # select features we want
  8. features = ['reanalysis_specific_humidity_g_per_kg',
  9. 'reanalysis_dew_point_temp_k',
  10. 'station_avg_temp_c',
  11. 'station_min_temp_c']
  12. df = df[features]
  13. # fill missing values
  14. df.fillna(method='ffill', inplace=True)
  15. print("adding labels to dataset...")
  16. # add labels to dataframe
  17. if labels_path:
  18. labels = pd.read_csv(labels_path, index_col=[0, 1, 2])
  19. df = df.join(labels)
  20. # separate san juan and iquitos
  21. sj = df.loc['sj']
  22. iq = df.loc['iq']
  23. return sj, iq
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...