简体   繁体   English

azuremlsdk R:如何将数据集转换为 R dataframe?

[英]azuremlsdk R: How to convert dataset into R dataframe?

For AzureML Python SDK we can use get_by_name() which returns the dataset.对于 AzureML Python SDK,我们可以使用 get_by_name() 返回数据集。

import azuremlsdk
mydata = get_by_name(myworkspace, 'mydata')

And I can get the panda dataframe of mydata by the.to_pandas_dataframe() method我可以通过.to_pandas_dataframe()方法得到mydata的熊猫dataframe

mydata.to_pandas_dataframe()

For R equivalent, I'm stuck here对于 R 等价物,我被困在这里

mydata <- azuremlsdk::get_dataset_by_name(myworkspace, 'mydata')

The question is, what are the options for R so that I get the tables, say, in csv or tibble?问题是,R 的选项是什么,以便我得到表格,比如 csv 或小标题?

I notice R's AzureML SDK is not as well documented as Python's, which makes migrating to AzureML pretty challenging for our R code base.我注意到 R 的 AzureML SDK 的文档记录不如 Python,这使得迁移到 AzureML 对于我们的 R 代码库非常具有挑战性。

An Azure Machine Learning Dataset allows you Load all records from the dataset into a dataframe and then Convert the current dataset into a FileDataset containing CSV files or Parquet files. Azure 机器学习数据集允许您将数据集中的所有记录加载到 dataframe 中,然后将当前数据集转换为包含 CSV 文件或 Parquet 文件的 FileDataset。

load_dataset_into_data_frame() => Load all records from the dataset into a dataframe. load_dataset_into_data_frame() => 将数据集中的所有记录加载到 dataframe 中。

convert_to_dataset_with_csv_files() => Convert the current dataset into a FileDataset containing CSV files. convert_to_dataset_with_csv_files() => 将当前数据集转换为包含 CSV 文件的 FileDataset。

convert_to_dataset_with_parquet_files() => Convert the current dataset into a FileDataset containing Parquet files. convert_to_dataset_with_parquet_files() => 将当前数据集转换为包含 Parquet 文件的 FileDataset。

Example: Convert data into dataframe.示例:将数据转换为 dataframe。

#' Load all records from the dataset into a dataframe.
#'
#' @description
#' Load all records from the dataset into a dataframe.
#'
#' @param dataset The Tabular Dataset object.
#' @return A dataframe.
#' @export
#' @md
load_dataset_into_data_frame <- function(dataset)   {
  dataset$to_pandas_data_frame()
}

#' Convert the current dataset into a FileDataset containing CSV files.
#'
#' @description
#' Convert the current dataset into a FileDataset containing CSV files.
#'
#' @param dataset The Tabular Dataset object.
#' @param separator The separator to use to separate values in the resulting file.
#' @return A new FileDataset object with a set of CSV files containing the data
#' in this dataset.
#' @export
#' @md

convert_to_dataset_with_csv_files <- function(dataset, separator = ",") {
  dataset$to_csv_files(separator)
}

#' Convert the current dataset into a FileDataset containing Parquet files.
#'
#' @description
#' Convert the current dataset into a FileDataset containing Parquet files.
#' The resulting dataset will contain one or more Parquet files, each corresponding
#' to a partition of data from the current dataset. These files are not materialized
#' until they are downloaded or read from.
#'
#' @param dataset The Tabular Dataset object.
#' @return A new FileDataset object with a set of Parquet files containing the
#' data in this dataset.
#' @export
#' @md
convert_to_dataset_with_parquet_files <- function(dataset) {
  dataset$to_parquet_files()
}

Reference: Azuremlsdk - working with datasets参考: Azuremlsdk - 使用数据集

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM