Map List of Tuples to New Column

前端 未结 2 519
一向
一向 2021-01-22 10:35

Suppose I have a pandas.DataFrame:

In [76]: df
Out[76]: 
          a         b  c
0 -0.685397  0.845976  w
1  0.065439  2.642052  x
2 -0.220823 -2.0         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-22 11:23

    Does this example help?

    class pandas.DataFrame(data=None, index=None, columns=None, dtype=None, copy=False)
    
    >>> d = {'col1': ts1, 'col2': ts2}
    >>> df = DataFrame(data=d, index=index)
    >>> df2 = DataFrame(np.random.randn(10, 5))
    >>> df3 = DataFrame(np.random.randn(10, 5),
    ... columns=['a', 'b', 'c', 'd', 'e'])
    

提交回复
热议问题