Showing posts with the label python-list-for-loop

Featured Post

How to Check Column Nulls and Replace: Pandas

Here is a post that shows how to count Nulls and replace them with the value you want in the Pandas Dataframe. We have explained the process in two steps - Counting and Replacing the Null values. Count null values (column-wise) in Pandas ## count null values column-wise null_counts = df.isnull(). sum() print(null_counts) ``` Output: ``` Column1    1 Column2    1 Column3    5 dtype: int64 ``` In the above code, we first create a sample Pandas DataFrame `df` with some null values. Then, we use the `isnull()` function to create a DataFrame of the same shape as `df`, where each element is a boolean value indicating whether that element is null or not. Finally, we use the `sum()` function to count the number of null values in each column of the resulting DataFrame. The output shows the count of null values column-wise. to count null values column-wise: ``` df.isnull().sum() ``` ##Code snippet to count null values row-wise: ``` df.isnull().sum(axis=1) ``` In the above code, `df` is the Panda

How to Use For loop List Option Quickly

For loop is main concept in Python programming. Out of all the For Loop options, the list option is so popular. If you know, how to use this concept, you can write any number of programs quickly and with less effort. Using for loop you can get index for list items. You can print list elements using for loop. If you take any language , the loops play a vital role. How to Use For Loop When you want to deal with data of multiple values, you need loops. So, For Loop is so famous because, you can control multiple input values. Syntax to Write For Loop for i in my_list: print(i) The 'i' says variable that represents value in the 'my_list'. The for helps to iterate the list values one by one. Example Program For Loop List in Python my_list=[2,3,4] for i in my_list: print(i) Result 2 3 4 How to create Multiplication Table using Python For-Loop List O