Create single row python pandas dataframe

In [399]: df = pd.DataFrame(columns=list('ABC'))

In [400]: df.loc[0] = [1,1.23,'Hello']

In [401]: df
Out[401]:
   A     B      C
0  1  1.23  Hello

or:

In [395]: df = pd.DataFrame([[1,1.23,'Hello']], columns=list('ABC'))

In [396]: df
Out[396]:
   A     B      C
0  1  1.23  Hello

Leave a Comment