pradeepsf729 / pandas_101

Pandas questions with solutions
1 stars 0 forks source link

3_count_9_Qs #6

Closed sandeepny441 closed 11 months ago

sandeepny441 commented 1 year ago

import pandas as pd

Create a dictionary containing your data

data = { 'worker_id': [1, 2, 3, 4, 5], 'first_name': ['Monika', 'Niharika', 'Vishal', 'Amitah', 'Vivek'], 'last_name': ['Arora', 'Verma', 'Singhal', 'Singh', 'Bhati'], 'salary': [100000, 80000, 300000, 500000, 500000], 'joining_date': ['2014-02-20 00:00:00', '2014-06-11 00:00:00', '2014-02-20 00:00:00', '2014-02-20 00:00:00', '2014-06-11 00:00:00'], 'department': ['HR', 'Admin', 'HR', 'Admin', 'Admin'] }

Create DataFrame

df = pd.DataFrame(data)

How would you use count to find the total number of rows in the DataFrame?

How can you use count to find the number of non-NA/null entries in the 'salary' column?

How would you apply count to find the number of non-NA/null entries for each column in the DataFrame?

Can you use count along with groupby to find out how many workers are in each department?

How can you use count to find out how many unique 'joining_date' values are present in the DataFrame?

How would you use count to determine the number of workers who have a salary greater than 100,000?

Is it possible to use count to find the number of workers with the last name 'Singh'? How would you do it?

Can you apply count to find the number of rows where both 'first_name' and 'last_name' are non-NA/null?

How would you use count to find the number of workers who joined before a certain date, for example, '2014-05-01'?