Programming Articles - Page 1376 of 3366

Python Pandas – How to use Pandas DataFrame tail( ) function

Vani Nalliappan
Updated on 27-May-2024 11:21:00

674 Views

Write a Python code to find price column value between 30000 to 70000 and print the id and product columns of the last three rows from the products.csv file. Result for price column value between 30000 to 70000 and id and product columns last three rows are −    id product 79 80 Truck 81 82 Bike 98 99 TruckSolution 1 Read data from products.csv file and assign to dfdf = pd.read_csv('products.csv ')Apply pandas slicing to access all rows of price column between 30000 to 50000 as, df[df.iloc[:, 4].between(30000, 50000)Save the above result to df1Apply slicing to access last ... Read More

Python Pandas – How to use Pandas DataFrame Property: shape

Vani Nalliappan
Updated on 29-Feb-2024 13:29:10

966 Views

Write a Python program to read data from the products.csv file and print the number of rows and columns. Then print the ‘product’ column value matches ‘Car’ for first ten rowsAssume, you have ‘products.csv’ file and the result for number of rows and columns and ‘product’ column value matches ‘Car’ for first ten rows are −Rows: 100 Columns: 8  id product engine avgmileage price height_mm width_mm productionYear 1 2  Car    Diesel    21      16500    1530    1735       2020 4 5  Car    Gas       18      17450    1530   ... Read More

How can Tensorflow Hub be used to fine-tune learning models?

AmitDiwan
Updated on 25-Feb-2021 07:42:50

309 Views

TensorFlow Hub is a repository that contains trained machine learning models. These models are ready to be fine-tuned and deployed anywhere. The trained models such as BERT and Faster R-CNN can be reused with a few lines of code. It is an open-repository, which means it can be used and modified by anyone.The tfhub.dev repository contains many pre-trained models. Some of them include text embeddings, image classification models, TF.js/TFLite models and so on.It can be installed using the below code:!pip install --upgrade tensorflow_hubIt can be imported into the working environment as shown in the below code:import tensorflow_hub as hub Read More

How can a customized model be pre-trained?

AmitDiwan
Updated on 25-Feb-2021 06:57:48

394 Views

A sequential model can be built using Keras Sequential API that is used to work with plain stack of layers. Here every layer has exactly one input tensor and one output tensor.A pre-trained model can be used as the base model on the specific dataset. This saves the time and resources of having to train the model again on the specific dataset.A pre-trained model is a saved network which would be previously trained on a large dataset. This large dataset would be a large-scale image-classification task. A pre-trained model can be used as it is or it can be customized ... Read More

Convert vowels from upper to lower or lower to upper using C program

Bhanu Priya
Updated on 24-Mar-2021 14:29:19

2K+ Views

An array of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example − char a[50]; string of length 50 charactersInitializationUsing single character constant −char a[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char a[10] = "Hello":;AccessingThere is a control string "%s" used for accessing the string till it encounters ‘\0’.The logic used to convert vowels from upper to lower or lower to upper is −for(i=0;string[i]!='\0';i++){    if(string[i]=='a'||string[i]=='e'||string[i]=='i'||string[i]=='o'||string[i]=='u'){       string[i]=toupper(string[i]);    } } printf("The result string with converted vowels is : "); puts(string);ProgramFollowing is the C program using conversion functions ... Read More

C Program to find the given number is strong or not

Sindhura Repala
Updated on 23-Jan-2025 10:53:45

43K+ Views

Recursive Factorial Calculation A strong number is a number, where the sum of the factorial of its digits equals the number itself. In C programming, a factorial is the product of all positive integers less than or equal to a given number. To calculate the factorial of a number, we use a recursive function with the argument N. This function will repeatedly call itself with a decremented value of N, multiplying the results until it reaches 1. 123!= 1!+2!+3!  =1+2+6 =9 In this case, 123 is not a strong number because the sum of the factorial of its digits ... Read More

C Program to find two’s complement for a given number

Bhanu Priya
Updated on 24-Mar-2021 14:25:47

17K+ Views

The two’s complement for a given binary number can be calculated in two methods, which are as follows −Method 1 − Convert the given binary number into one’s complement and then, add 1.Method 2 − The trailing zero’s after the first bit set from the Least Significant Bit (LSB) including one that remains unchanged and remaining all should be complementing.The logic to find two’s complement for a given binary number is as follows −for(i = SIZE - 1; i >= 0; i--){    if(one[i] == '1' && carry == 1){       two[i] = '0';    }    else ... Read More

What is enumerated data type in C language?

Bhanu Priya
Updated on 24-Mar-2021 14:24:31

3K+ Views

These are used by the programmers to create their own data types and define what values the variables of these datatypes can hold.The keyword is enum.SyntaxThe syntax for enumerated data type is as follows −enum tagname{    identifier1, identifier2, ……., identifier n };ExampleGiven below is an example for enumerated data type −enum week{    mon, tue, wed, thu, fri, sat, sun };Here, Identifier values are unsigned integers and start from 0.Mon refers 0, tue refers 1 and so on.ExampleFollowing is the C program for enumerated data type − Live Demo#include main ( ){    enum week {mon, tue, wed, thu, fri, ... Read More

C Program to delete the duplicate elements in an array

Bhanu Priya
Updated on 12-Sep-2023 03:23:56

53K+ Views

Try to delete the same numbers present in an array. The resultant array consists of unique elements.The logic to delete the duplicate elements in an array is as follows −for(i=0;i

How to merge to arrays in C language?

Bhanu Priya
Updated on 24-Mar-2021 14:22:04

6K+ Views

Take two arrays as input and try to merge or concatenate two arrays and store the result in third array.The logic to merge two arrays is given below −J=0,k=0 for(i=0;i

Advertisements