Friday, 15 February 2013

python create a data frame with one row by a list -


In the dragon

says, I have a list [1,2,3, ..., 100], and I Would like to use this list to create dataframe in which there is a row and a row value list. What is the fastest and elegant way to do this?

List to data :

  In [11]: l = Category (1,100) pd.DataFrame (Data = [L]) Out [11]: 0 1 2 3 4 5 6 7 8 9 ... 89 90 91 92 93 93 94 95 96 0 1 2 3 4 5 6 7 8 9 10 ... 90 91 92 93 94 95 96 97 97 98 98 99 [1 row x 99 column]  

You can use the DataFrame For constructors, the column names can be passed as ARGs or can be assigned directly:

pd.DataFrame (data = [L], column = call_list) < / P>

or

  df.columns = col_list  

No comments:

Post a Comment