You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replacing the current version of add_entity.R corrects the issue:
#' add_entity
#' @description Add an entity to an entityset.
#' @export
#'
#' @param entityset The entity set to modify.
#' @param entity_id The name of the entity to add.
#' @param df The data frame to add as an entity.
#' @param index The index parameter specifies the column that uniquely identifies rows in the dataframe
#' @param time_index Name of the time column in the dataframe.
#' @param ... Additional parameters passed to `featuretools.entity_from_dataframe`.
#' @return A modified entityset.
#'
#' @examples
#' \donttest{
#' library(magrittr)
#' create_entityset("set") %>%
#' add_entity(df = cars,
#' entity_id = "cars",
#' index = "row_number")
#' }
add_entity <- function(
entityset,
entity_id,
df,
index = NULL,
time_index = NULL,
...
) {
# Construct logical_types to handle factors as categorical variables.
classes <- purrr::map_dfr(sapply(df, FUN = function(col) {
c <- class(col)
# prettify difficult data types
if(length(c > 1))
c <- paste0(c, collapse = ", ")
return(c)
}), c)
logical_types = list() #initialize
if (any(classes == "factor")) {
for (i in 1:length(classes)) {
suppressWarnings({
if (class(df[, i]) == "factor") {
logical_types[[names(df)[i]]] <- .Categorical
}
})
}
}
logical_types <- reticulate::r_to_py(logical_types)
# Add df as entity to entityset.
es <- entityset$add_dataframe(
dataframe_name = entity_id,
dataframe = reticulate::r_to_py(x = df),
index = index,
time_index = time_index,
logical_types = logical_types,
...
)
return(es)
}
Hi there, great that you found a solution. I'm not really working with R currently, but if you'd like to submit this as a PR (and update tests if required), I can create a new release for it (and send to CRAN).
When following the instructions in the README, under the 'Creating and EntitySet' heading. The following code results in an error:
The error states:
Session Info:
The text was updated successfully, but these errors were encountered: