generating errors we’ve already seen the raise keyword, in passing raise Exception is the simplest way to have your program stop when something goes wrong in a notebook/console environment, it stops the current cell/function (doesn’t crash the session) you have to raise <something> Exception is the most general case (“something happened”) other possibilities TypeError: someContinue Reading

Find duplicate rows: duplicated() Determines which duplicates to mark: keep Specify the column to find duplicate: subset Count duplicate / non-duplicate rows Remove duplicate rows: drop_duplicates() keep, subset inplace Aggregate based on duplicate elements: groupby() The following data is used as an example. row #6 is a duplicate of row #3. The sample csv file is linked below. FindContinue Reading

There are two kinds of sorting available in Pandas. They are − By label By Actual Value Let us consider an example with an output. import pandas as pd import numpy as np unsorted_df=pd.DataFrame(np.random.randn(10,2),index=[1,4,6,2,3,5,9,8,0,7],colu mns=[‘col2′,’col1’]) print unsorted_df Its output is as follows − col2 col1 1 -2.063177 0.537527 4 0.142932 -0.684884 6Continue Reading