Day 5 of #100daysofcode #Dataengineering
Greetings to you my dear reader, I want to say thank you for always taking out time to see how I'm progressing towards my career path.
Today I will try as much as possible to be brief. To be honest I always enjoy sitting on the PC for hours without course for alarm. This challenge has bring more of that to light. And this shows I'm happy about the progress.
Yeh! Incase you missed my previous post, you need to go back and read it... Nah I'm just kidding, let me brief you what this journey is all about. In a sentence. It's all about coding and it's titled #100daysofcode the goal is to be a proficient data engineer using SQL and python by the end of 100th day. Now that you know, Read along how I spent my day leaning and practicing coding.
Today I focuses more on Adding/Dropping Sorting and Renaming of Rows amd columns.
Adding/Dropping
Deletion of column/rows
Here I learnt how to use the drop function to delete a column. With drop function() I can delete one or multiple rows or columns
Case 1: Say I want to remove a row in a dataframe, all I have to do was👇
Julius.drop(index=4)
The index=4 means that I'm deleting the row with index 4. So key point here is that, one need to be sure of the index before dropping the row and same can be said across columns. Just to add, in other for the changes to be permanent all I have to do is to apply the inplace=True
Case 2: Adding a row to a dataframe.
Before adding a row into the already existing dataframe, all I need to do first was to pass a list and thereafter I append it with the already existing dataframe. Consider the codes below on how I did that.
I already passed a list with a variable 'Jane'
and assuming my already existing dataframe is 'Hospice'
Jane=pd.DataFrame(Hospice)
#appending
Hospice.append(Jane, ignore_index=True, sort=False)
Sorting and Renaming :
Sorting a dataframe by row and column : Sorting multiple columns
Case 1: today I sorted dataframe with last_name and first_name in both Ascending and Descending order.
Julius.sort_values(by=['last_name', ' last_name'], ascending =False, True])
I also sorted numerical data checking the employee to see the staff that earn the highest salary.
Julius_emp.nlargest(10, 'salary')
The above code returns the 10 largest paying staff in the salary column.
Congratulations 👏 you made it to the end. Here is where I will call it a day. See you tomorrow for another challenge. Julius loves you.
Post a Comment