KnowledgeBoat Logo
|

Informatics Practices

Create a dataframe using list [10, 11, 12, 13, 14] [23, 34, 45, 32, 65] [55, 60, 65, 70, 75] and do the following:

(a) Display the dataframe.

(b) Add the list [1, 2, 3, 4, 5] to dataframe and display it.

Python Data Handling

2 Likes

Answer

(a)

import pandas as pd

data = [[10, 11, 12, 13, 14],
        [23, 34, 45, 32, 65],
        [55, 60, 65, 70, 75]]
df = pd.DataFrame(data)

print(df)
Output
    0   1   2   3   4
0  10  11  12  13  14
1  23  34  45  32  65
2  55  60  65  70  75

(b)

df.loc[3] = [12, 62, 53, 34, 75]
print(df)
Output
    0   1   2   3   4
0  10  11  12  13  14
1  23  34  45  32  65
2  55  60  65  70  75
3  12  62  53  34  75

Answered By

1 Like


Related Questions