convert list to five columns dataframe in sequence - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: convert list to five columns dataframe in sequence (/thread-29997.html) |
convert list to five columns dataframe in sequence - tonycat - Sep-29-2020 I am new to programming and python, need help to convert the list to five columns Dataframe , but keep the sequences 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: "cat1","cat2","blue","color","coffe" "mary","David","dog","clever","stupid" 1,2,3,4,5 "A","b","c","d","e" thank a lot RE: convert list to five columns dataframe in sequence - buran - Sep-29-2020 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)) print(df)
RE: convert list to five columns dataframe in sequence - tonycat - Sep-29-2020 thank |