Reputation: 3
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.
Upvotes: 0
Views: 60
Reputation: 579
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.
Upvotes: 2