流水线
凭借 Python、命令行和 Jupyter 接口,ydata-profiling
可以与 Airflow、Dagster、Kedro 和 Prefect 等 DAG 执行工具无缝集成,使其轻松成为数据摄取和分析流水线的基本构建块。与 Dagster 或 Prefect 的集成方式与 Airflow 类似。
YData Fabric 流水线
Fabric 社区版
YData Fabric 提供社区版,您可以立即开始使用它来创建数据工作流程和流水线。在此注册并开始构建您的流水线。ydata-profiling 在所有 YData 镜像中默认安装。

YData Fabric 的数据流水线旨在利用 Kubeflow 的功能,为可扩展且高效的数据工作流程提供坚实的基础。这种技术集成确保数据流水线能够无缝处理大量数据并以最佳资源利用率执行操作。
YData Fabric 通过抽象复杂性来简化数据流水线设置流程。设置通过拖放体验完成,同时利用现有的 Jupyter Notebook 环境。观看此视频了解 如何在 YData Fabric 中创建流水线。
在流水线中使用 ydata-profiling 对 csv 文件进行分析 |
---|
| # Import required packages
import json
import pandas as pd
from ydata.profiling import ProfileReport
# Read your dataset as a CSV
dataset = pd.read_csv('data.csv')
# Instantiate the report
report = ProfileReport(dataset, title="Profiling my data")
report.config.html.navbar_show = False #disable the navigation bar
# get the report html
report_html = report.to_html()
#Output visually in the pipeline
metadata = {
'outputs' : [
{
'type': 'web-app',
'storage': 'inline',
'source': report_html,
}
]
}
#write the visual outputs in the pipeline flow
with open('mlpipeline-ui-metadata.json', 'w') as metadata_file:
json.dump(metadata, metadata_file)
|
您可以在 ydata-profiling 示例文件夹中找到包含此实现的 notebook。
Airflow
与 Airflow 的集成可以通过 BashOperator 或 PythonOperator 轻松实现。
在 Airflow 中使用 ydata-profiling |
---|
| # Using the command line interface
profiling_task = BashOperator(
task_id="Profile Data",
bash_command="pandas_profiling dataset.csv report.html",
dag=dag,
)
|
在 Airflow 中使用 ydata-profiling |
---|
| # Using the Python interface
import ydata_profiling
def profile_data(file_name, report_file):
df = pd.read_csv(file_name)
report = pandas_profiling.ProfileReport(df, title="Profiling Report in Airflow")
report.to_file(report_file)
return "Report generated at {}".format(report_file)
profiling_task2 = PythonOperator(
task_id="Profile Data",
op_kwargs={"file_name": "dataset.csv", "report_file": "report.html"},
python_callable=profile_data,
dag=dag,
)
|
Kedro
有一个社区创建的 Kedro 插件可用。
