Dataframe Manipulations
- 1 Remove elements from a pandas DataFrame using drop() and truncate() Methods Rows and columns can be removed from a DataFrame using the methods drop() and truncate(). While select rows and columns can be removed using drop(), thresholds can be specified for rows and column indices while calling the truncate() method to remove unwanted rows/columns. 30 Nov 2019
- 2 Removing missing values and duplicate values from a pandas DataFrame Missing values and duplicate values are real problems that exist in data streams which creates smaller to catastrophic issues. DataFrame class of pandas framework has methods dropna() and drop_duplicates() to remove them in a comprehensive way. 1 May 2021
- 3 Making a new row using each element of a sequence present in a DataFrame column The explode() method of pandas DataFrame make a new row out of each element from a sequence, where the sequence is an element of the DataFrame column. 1 Dec 2019
- 4 Retrieve elements from the head and tail of a pandas DataFrame The head() method selects first 'n' elements from a DataFrame instance. Similarly, the tail() method of the DataFrame class selects the last 'n' number of rows. 29 Nov 2019
- 5 Querying a pandas DataFrame A pandas DataFrame can be queried using many of its methods. They include the methods at(), iat(), head(), tail(), query(), asof(), items(), iteritems() and the properties loc and iloc. 20 Aug 2020
- 6 Replacing pandas DataFrame elements The pandas DataFrame class offers the replace() and mask() methods to replace the elements of a DataFrame. While the mask() works through a Boolean expression the replace() works by using the values directly. 17 Aug 2020
- 7 Creating a random sample from a pandas DataFrame The sample() method of the DataFrame class returns a random sample. The parameter random_state is used as the seed for the random number generator to get the same sample every time the program runs. 29 Jul 2020