Answers for "python create dataframe by row"

0

python create dataframe by row

In [7]: df = pandas.DataFrame(columns=['a','b','c','d'], index=['x','y','z'])
In [8]: df.loc['y'] = pandas.Series({'a':1, 'b':5, 'c':2, 'd':3})
In [9]: df
Out[9]: 
     a    b    c    d
x  NaN  NaN  NaN  NaN
y    1    5    2    3
z  NaN  NaN  NaN  NaN
Posted by: Guest on May-24-2021

Code answers related to "python create dataframe by row"

Python Answers by Framework

Browse Popular Code Answers by Language