Why can't I chain the get_dummies() function?
import pandas as pd df = (pd .read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv') .drop(columns=['sepal_length']) .get_dummies() ) This works fine:
df = (pd .read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv') .drop(columns=['sepal_length']) ) df = pd.get_dummies(df)
get_dummiesis a pandas function not a method for dataframe. In the first try, you're trying tp apply a function on a dataframe.pd.Series.str.get_dummies()which is a series method. Details in my answer.