Posts

Showing posts from April, 2023

Swap Program with temporary variable using JAVA

Image
WHAT IS SWAP: Swapping is the process of changing the values of two variables.  Able to change the values of two variables in different ways. SWAP PROGRAM WITH TEMPORARY VARIABLE USING JAVA:      Swap the values of two variables with the use of the temporary variable.       In the above image, we have two boxes. The first box has a red ball and the second box has a green ball. We have to exchange the balls in the two boxes.      Using a temporary box, we have to swap the balls in the boxes. PROGRAM: import java.lang.*; class Swap { public static void main(String args[]) { int a = 10, b=20, temp; System.out.println("Before Swapping: a = " + a + " b = " + b); temp = a; a = b; b = temp; System.out.println("After Swapping: a = " + a + " b = " + b); } } Output:                                           ...

Pandas DataFrame empty

Image
HOW TO CHECK IF THE DATAFRAME IS EMPTY OR NOT? Check if the DataFrame is empty or not by using the  DataFrame.empty .  It returns the Boolean value. If the DataFrame is empty, then it returns True . If the DataFrame is not empty, then it returns False . CREATE A EMPTY DATAFRAME: Create an empty dataframe and will check if it is empty or not by using the property DataFrame.empty If it is empty, then it returns True. import  pandas as pd  empty_dataframe = pd.DataFrame() if empty_dataframe.empty:       print ('True') CREATE A NON-EMPTY DATAFRAME: Create a non-empty dataframe and will check if the dataframe is empty or not.  If it is not empty, then it returns False. import  pandas as pd  pd_dataframe= pd.DataFrame( [['Vetri',20],['Vishal',21],['Jack',18]],   columns=['Name', 'Age'] ) if  pd_dataframe .empty is False:      print ('False') Thanks for choosing our blog 😊.