You are on page 1of 1

WAP to create dataframe from 2d list

Import pandas as pd

List2 = [[25, 30, 35], [47, 68, 38], [40, 45, 55]]

Df2 = pd.DataFrame(list2, index = [“row1”, “row2”, “row3”], columns = [A, B, C])

print(Df2)

import numpy as np

import pandas as pd

arr1 = np.array([[11, 12], [13, 14], [15,16]], np.int32)

df3 = pd.DataFrame(arr1)

print(df3)

python way -

n=1

while n <=9:

print(n, end = ‘ ’)

x = n%3

if x = 0:

print(/n)

else:

n = n +1

spyder way –

a = np.arange(1, 10)

a = a.reshape(3, 3)

df = pd.DataFrame(a)

print(df)

Q. Create a dataframe for four cities depicting toys, books and uniform shops

You might also like