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
  Convert each element of a list to a string for processing tester_V 6 358 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 450 Jun-07-2021, 06:09 AM
Last Post: ricslato
  convert numbers into list lokesh 1 291 Jun-03-2021, 06:37 AM
Last Post: menator01
  Reading data to python: turn into list or dataframe hhchenfx 2 196 Jun-01-2021, 10:28 AM
Last Post: Larz60+
  Create SQLite columns from a list or tuple? snakes 6 500 May-04-2021, 12:06 PM
Last Post: snakes
Question convert unlabeled list of tuples to json (string) masterAndreas 4 646 Apr-27-2021, 10:35 AM
Last Post: masterAndreas
  Convert MultiLayer XML to DataFrame using Pandas vsingh17 0 420 Apr-14-2021, 03:50 PM
Last Post: vsingh17
Star Convert Bytearray into List using list() Shlok 2 395 Feb-18-2021, 10:44 AM
Last Post: deanhystad
  How to sum across variable columns in a dataframe rennerom 2 537 Jan-31-2021, 05:44 PM
Last Post: rennerom
  convert List with dictionaries to a single dictionary iamaghost 3 527 Jan-22-2021, 03:56 PM
Last Post: iamaghost

Forum Jump:

User Panel Messages

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