Python Forum
convert list to five columns dataframe in sequence
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert list to five columns dataframe in sequence
I am new to programming and python, need help to convert the list to five columns Dataframe , but keep the sequences Huh Huh

small sample from my list:

list_of_cats = ["cat1","cat2","blue","color","coffe","mary","David","dog","clever","stupid",1,2,3,4,5,"A","b","c","d","e"]
five columns dataframe
like this:


thank a lot Rolleyes Rolleyes
import pandas as pd
import numpy as np

list_of_cats = ["cat1","cat2","blue","color","coffe","mary","David","dog","clever","stupid",1,2,3,4,5,"A","b","c","d","e"]
df = pd.DataFrame(np.array(list_of_cats).reshape(4,5))
0 1 2 3 4 0 cat1 cat2 blue color coffe 1 mary David dog clever stupid 2 1 2 3 4 5 3 A b c d e
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

thank Big Grin Big Grin Big Grin

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cannot convert the series to <class 'int'> when trying to create new dataframe column Mark17 3 93 Jan-20-2022, 05:15 PM
Last Post: deanhystad
  Need to parse a list of boolean columns inside a list and return true values Python84 4 263 Jan-09-2022, 02:39 AM
Last Post: Python84
  List of dataframe values beginning with x,y or z glidecode 3 418 Nov-08-2021, 10:16 PM
Last Post: glidecode
  Apply fillna to multiple columns in dataframe rraillon 2 646 Aug-05-2021, 01:11 PM
Last Post: rraillon
  Convert each element of a list to a string for processing tester_V 6 1,589 Jun-16-2021, 02:11 AM
Last Post: tester_V
  How to rename dataframe columns based on the content in an index? ar_mahdavi 2 1,031 Jun-07-2021, 06:09 AM
Last Post: ricslato
  convert numbers into list lokesh 1 974 Jun-03-2021, 06:37 AM
Last Post: menator01
  Reading data to python: turn into list or dataframe hhchenfx 2 1,162 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  Create SQLite columns from a list or tuple? snakes 6 2,219 May-04-2021, 12:06 PM
Last Post: snakes
Question convert unlabeled list of tuples to json (string) masterAndreas 4 3,012 Apr-27-2021, 10:35 AM
Last Post: masterAndreas

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020