You can get the number of rows in Pandas DataFrame using len(df.index) and df.shape[0] properties. Pandas allow us to get the shape of the DataFrame by counting the number of rows in the DataFrame. DataFrame.shape property returns the rows and columns, for rows get it from the first index which is zero; like df.shape[0] and for columnsContinue Reading

While working in Pandas DataFrame or any table-like data structures we are often required to change the data type(dtype) of a column also called type casting, for example, convert from int to string, string to int e.t.c, In pandas, you can do this by using several methods like astype(), to_numeric(), covert_dttypes(), infer_objects() and e.t.c. InContinue Reading

Use drop() method to delete rows based on column value in pandas DataFrame, as part of the data cleansing, you would be required to drop rows from the DataFrame when a column value matches with a static value or on another column value. In this article, I will explain dropping rows based on column value.Continue Reading

How to drop column(s) by index in Pandas? You can use the drop() function in Pandas to remove columns by index. Set the axis parameter to 1 (indicating columns) and specify either the single-column index or a list of column indices you want to eliminate. In this article, I will explain how to dropContinue Reading

By using pandas.DataFrame.drop() method you can drop/remove/delete rows from DataFrame. axis param is used to specify what axis you would like to remove. By default axis=0 meaning to remove rows. Use axis=1 or columns param to remove columns. By default, Pandas return a copy DataFrame after deleting rows, used inpalce=True to remove from existing referring DataFrame. In this article, I will cover howContinue Reading

Pandas DataFrame.rename() function is used to change the single column name, multiple columns, by index position, in place, with a list, with a dict, and renaming all columns, etc. We are often required to change the column name of the DataFrame before we perform any operations. In fact, changing theContinue Reading

 In Pandas, you can add a new column to an existing DataFrame using the DataFrame.insert() function, which updates the DataFrame in place. Alternatively, you can use DataFrame.assign() to insert a new column, but this method returns a new DataFrame with the added column. Advertisements In this article, I will cover examples of adding multipleContinue Reading

You can use DataFrame properties loc[], iloc[], at[], iat[] and other ways to get/select a cell value from a Pandas DataFrame. Pandas DataFrame is structured as rows & columns like a table, and a cell is referred to as a basic block that stores the data. Each cell contains information relating to the combination ofContinue Reading

The pandas.DataFrame.query() method is used to query rows based on the provided expression (single or multiple column conditions) and returns a new DataFrame. If you want to modify the existing DataFrame in place, you can set the inplace=True argument. This allows for efficient filtering and manipulation of DataFrame data without creating additional copies. InContinue Reading

 In Pandas, selecting columns by name or index allows you to access specific columns in a DataFrame based on their labels (names) or positions (indices). Use loc[] & iloc[] to select a single column or multiple columns from pandas DataFrame by column names/label or index position respectively. In this article, I will explain howContinue Reading