Create Empty Dataframe in Pandas specifying column types

前端 未结 11 1944
萌比男神i
萌比男神i 2020-11-28 08:39

I\'m trying to create an empty data frame with an index and specify the column types. The way I am doing it is the following:

df = pd.DataFrame(index=[\'pbp\         


        
11条回答
  •  难免孤独
    2020-11-28 09:00

    Just a remark.

    You can get around the Type Error using np.dtype:

    pd.DataFrame(index = ['pbp'], columns = ['a','b'], dtype = np.dtype([('str','float')]))
    

    but you get instead:

    NotImplementedError: compound dtypes are not implementedin the DataFrame constructor
    

提交回复
热议问题