如何将数据框转换为 great_expectations 数据集?

How do you convert a dataframe to a great_expectations dataset?

我有一个 pandas 或 pyspark 数据框 df,我想在其中 运行 一个期望值。 我已经在内存中有了我的数据框。如何将我的数据框转换为 great_expectations 数据集?

这样我就可以做例如:

df.expect_column_to_exist("my_column")
import great_expectations as ge

对于 pandas:

df_ge = ge.from_pandas(df)

df_ge = ge.dataset.PandasDataset(df)

对于 pyspark:

df_ge = ge.dataset.SparkDFDataset(df)

现在您可以运行您的期望

df_ge.expect_column_to_exist("my_column")

Note that the great_expectations SparkDFDataset does not inherit the functions from the pyspark DataFrame. You can access the original pyspark DataFrame by df_ge.spark_df

另请参阅远大前程 documentation/tutorial,了解使用 ge.from_pandas 转换 Pandas DF 的替代版本:https://docs.greatexpectations.io/en/latest/guides/tutorials/explore_expectations_in_a_notebook.html