-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
40 lines (25 loc) · 863 Bytes
/
utils.py
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
38
39
40
import pandas as pd
import numpy as np
import os
import json
pd.set_option("display.max_columns", None)
def load_to_pickle(working_set, path):
path = f"Dataset_Files/{path}.pkl"
working_set.to_pickle(path)
def load_from_pickle(path):
path = f"Dataset_Files/{path}.pkl"
return pd.read_pickle(path)
def load_to_csv(working_set, path):
path = f"Dataset_Files/{path}.csv"
working_set.to_csv(path, index=False)
def load_from_csv(path):
path = f"Dataset_Files/{path}.csv"
return pd.read_csv(path)
def load_to_numpy(array, path):
path = f"Dataset_Files/{path}.npy"
np.save(path, array)
def load_from_numpy(path):
path = f"Dataset_Files/{path}.npy"
return np.load(path, allow_pickle=True)
def replace_with_nan(working_set, string_to_replace):
working_set.replace(string_to_replace, np.NaN, inplace=True)