Create Single Row Python Pandas Dataframe
I want to create a python pandas DataFrame with a single row, to use further pandas functionality like dumping to *.csv. I have seen code like the following being used, but I only
Solution 1:
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
Post a Comment for "Create Single Row Python Pandas Dataframe"