I want to change the data type that could be entered in an empty Pandas data frame. So I've tried the following approach but it doesn't work. can someone please give me a hint how to solve this issue?
columns=['A', 'B', 'C', 'D', 'E','F']
df = pd.DataFrame(columns=columns)
>>> df
Empty DataFrame
Columns: [A, B, C, D, E, F]
Index: []
df[[0]]=df[[0]].astype(str)
df[[1]]=df[[1]].astype(str)
df[[2]]=df[[2]].astype(int)
df.iloc[:,3:6]=df.iloc[:,3:6].astype(float)
df = pd.DataFrame(columns=columns, dtype=str)df = pd.DataFrame(columns=columns, dtype=str)will givedf.dtypesasobjects