forked from Smartitect/dataprep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonCode.py
More file actions
40 lines (34 loc) · 1.45 KB
/
Copy pathcommonCode.py
File metadata and controls
40 lines (34 loc) · 1.45 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
38
39
40
# Import all of the libraries we need to use
import pandas as pd
import azureml.dataprep as dprep
import seaborn as sns
import os as os
import re as re
import collections
from azureml.dataprep import value
from azureml.dataprep import col
from azureml.dataprep import Package
# Let's also set up global variables and common functions...
# NOTE - still to figure out how to do this from a single file and import it successfully.
#%%
# Path to the source data
dataPath = "./data"
# Path to the location where the dataprep packags that are created
packagePath = "./packages"
# Name of package file
packageFileSuffix = "_package.dprep"
# A helper function to create full package path
def createFullPackagePath(packageName, stage, qualityFlag):
return packagePath + '/' + packageName + '_' + stage + '_' + qualityFlag + packageFileSuffix
# A save package helper function
def savePackage(dataFlowToPackage, packageName, stage, qualityFlag):
dataFlowToPackage = dataFlowToPackage.set_name(packageName)
packageToSave = dprep.Package(dataFlowToPackage)
fullPackagePath = createFullPackagePath(packageName, stage, qualityFlag)
packageToSave = packageToSave.save(fullPackagePath)
# An open package helper function
def openPackage(dataFlowToPackage, packageName, stage, qualityFlag):
fullPackagePath = createFullPackagePath(packageName, stage, qualityFlag)
packageToOpen = Package.open(fullPackagePath)
dataFlow = packageToOpen[packageName]
return dataFlow