Example #1
0
]

#  Excel sheets to exclude
exclude = ['Category', 'NS1TRIP']

# Read all data sheets
data = pd.read_excel(path_fixed, sheet_name=None)
tmps = pd.read_excel(path_ccfgs, sheet_name=None)

# Create blender
blender = Blender(widgets=[
    DateTimeMergeWidget(),
    RenameWidget(),
    ReplaceWidget(),
    #TemplateTransformWidget(),
    EventWidget()
])

# Fit blender to templates.
blender = blender.fit(info=tmps)

# Transform data
transformed = blender.transform(data, include=include, exclude=exclude)

# Stacked data
stacked = blender.stack(transformed,
                        index='study_no',
                        include=include,
                        exclude=exclude)

# Save stack data
Example #2
0
    'StudyNo': '32dx-003',
    'DateEnrol': '2020/12/08',
    'LabStudyDay': 0
}, {
    'StudyNo': '32dx-004',
    'DateEnrol': '2020/12/11',
    'LabStudyDay': 10
}, {
    'StudyNo': '32dx-005',
    'LabStudyDay': 3
}, {
    'StudyNo': '32dx-005',
    'DateEnrol': '2020/12/07'
}]

# Blender template
bt = BlenderTemplate().fit(template)

# Create data
data = pd.DataFrame(data)

# Create widgets and transform
trans = RenameWidget().fit_transform(bt, data)
trans = DateFromStudyDayWidget().fit_transform(bt, trans)
trans = EventWidget().fit_transform(bt, trans)

# Show
print("\nOriginal:")
print(data)
print("\nTransformed:")
print(trans)
Example #3
0
# Create DataFrames
template = pd.DataFrame(template)
data = pd.DataFrame(data)

#template = template.drop(columns=['timestamp'])
#template.timestamp = None
#template.event = None
#template = template.drop(columns=['to_name'])

# Transformed (order matters!)
transformed = RenameWidget().fit_transform(template, data)
transformed = TemplateTransformWidget().fit_transform(template, transformed)
transformed = ReplaceWidget().fit_transform(template, transformed)
transformed = DateTimeMergeWidget().fit_transform(template, transformed)
transformed = DateFromStudyDayWidget().fit_transform(template, transformed)
transformed = EventWidget().fit_transform(template, transformed)

# Stack data
stacked = StackWidget(index=['study_number']) \
    .fit_transform(template, transformed)

# Show
print("\nOriginal:")
print(data)
print("\nTransformed:")
print(transformed)
print("\nStacked:")
print(stacked)

# Show data types
print("\n")