list = [[1,1,56],
[20,2,78],
[30,3,34],
[40,4,98]]
this is my list of list and i want to make a dataframe like this-;
a b c
1 1 56
20 2 78
30 3 34
40 4 98
i did a code
df = pd.DataFrame(list)
df = df.transpose()
df.columns = ["a", "b", "c"]
it gives me a error like Length mismatch: Expected axis has 4 elements, new values have 3 elements
please help me thanks in advance
df = pd.DataFrame(L, columns=["a", "b", "c"])?df = pd.DataFrame(list)gives you a df of dimensions (4 rows, 3 cols). Transpose changes it to (3 rows, 4 cols) and then you will have to 4 col names instead of three.