简体   繁体   中英

How to get a 2d DataFrame from 1d Series data

How to get a 2d DataFrame from 1d Series data.

I have data x,

x=[1,2,3,....,99]

How can I get a 2d matrix DataFrame:

{[1,2,3,...,99],[1,2,3,...,99],[1,2,3,...,99]....[1,2,3,....,99]}

(the DataFrame is a 100 raws 50 columns matrix).

from pandas import DataFrame,Series
import numpy as np
x=Series(np.arange(1,100))

You can convert a list of lists directly into a dataframe.

from pandas import DataFrame

li =[list(range(10))]*5
df = DataFrame(li)
print (df)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM