I am trying to pass dataframe and variable functions to plot some function using plotnine in python. I am new to python. Is it possible to do so. My code is
def countPred_eda(dataset, variableName, targetVariable):
print(dataset.variableName.describe())
ggplot(dataset) + \
aes(targetVariable, variableName, fill = targetVariable) + geom_boxplot(alpha = .8) + \
labs(x = targetVariable, y = variableName) + \
ggtitle("Churn ratio with number_customer_service_calls ")
calling as
countPred_eda(train_data, number_customer_service_calls,churn)
Assumed that dataset
is of type pd.DataFrame and variableName
and targetVariable
are two strings which hold the names of two columns in this dataframe, you can do it like this with two exceptions:
dataset.variableName.describe()
you have to use indexing syntax like dataset[variableName].describe()
aes
belong inside the brackets directly behind dataset
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.