0

I have a list that contains some values from a store (ex: revenue, net profit and sale price), but i have 99 stores to collect those values and create a dataframe with than. The WebScraping part i'm using 'for' and a function to collect. My problem is how i move a list, that has other lists inside her, to a dataframe using pandas.

1
  • always put code in question, not in comment. it will be more readable and more people will see it. Commented Sep 2, 2020 at 0:50

1 Answer 1

2

You can use the DataFrame method built in pandas:

data = [["First", "List", "Item"], ["Second", "List", "Item"], ["Third", "List", "Item"]]
df = pd.DataFrame(data)

df
        0     1     2
0   First  List  Item
1  Second  List  Item
2   Third  List  Item

You can also use the Transpose method to get the data arranged differently:

data = [["First", "List", "Item"], ["Second", "List", "Item"], ["Third", "List", "Item"]]
df = pd.DataFrame(data).T

df
       0       1      2
0  First  Second  Third
1   List    List   List
2   Item    Item   Item

Here is the official documentation for the function.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.