type object 'object' has no attribute 'dtype' when create dataframe from pandas 1

type object ‘object’ has no attribute ‘dtype’ when create dataframe from pandas

column_names = ["a", "b", "c"]
df = pd.DataFrame(columns = column_names, dtype=object)

Here is what the above code is Doing:
1. We create a list of column names.
2. We create a DataFrame with the column names.
3. We set the dtype to object.

The dtype is set to object because we want to store the data as strings.

Similar Posts