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
Create a dataframe of dictionary consisting of Name, Sub1, Sub2, Sub3, Sub4, Sub5 of five students.
(a) Display the dataframe.
(b) Display the first 5 rows and bottom 3 rows of student dataframe.
Create two dataframes of salary of five employees and do the following:
(a) Display both the dataframes.
(b) Add 5000 as bonus in both dataframes and display them.
Create a dataframe of [23, 25], [34], [43, 44, 45, 46] and do the following: :
(a) Display the dataframe. Notice that the missing value is represented by NaN.
(b) Replace the missing value with 0.
(c) Replace the missing value with -1, -2, -3, -4 for columns 0, 1, 2, 3.
(d) Replace the missing value by copying the value from the above cell.
Create a dataframe of D1 and D2;
D1 = {‘Rollno’ : [1001, 1004, 1005, 1008, 1009], ‘Name’: [‘Sarika’, ‘Abhay’, ‘Mohit’, ‘Ruby’, ‘Govind’ ]}
D2 = {‘Rollno’ : [1002, 1003, 1004, 1005, 1006], ‘Name’:[‘Seema’,‘Jia’,‘Shweta’, ‘Sonia’, ‘Nishant’]}(a) Concatenate row-wise.
(b) Concatenate column-wise.