import pandas as pd
from sklearn.preprocessing import OneHotEncoder
df = pd.DataFrame({'Fruit': ['apple', 'banana', 'cherry', 'apple', 'banana']})
# create an instance of OneHotEncoder
encoder = OneHotEncoder()
# fit and transform the categorical variable
dummies = encoder.fit_transform(df[['Fruit']])
# convert the sparse matrix to a dataframe
dummies = pd.DataFrame.sparse.from_spmatrix(dummies)
# concatenate the dummy variables to the original dataframe
df = pd.concat([df, dummies], axis=1)
print(df)