Found 34488 Articles for Programming

Difference Between Tensor and Variable in Pytorch

Jaisshree
Updated on 10-Aug-2023 14:34:00

180 Views

PyTorch is an open-source Python library used for machine learning, computer vision and deep learning. It is an excellent library to build neural networks, conduct complex computations and optimise gradient differentiation. Developed by Facebook's Research Team (FAIR), it gained popularity due to its dynamic computing graphs, allowing it to change graphs in real time. This was revolutionary back in 2016 when models working in real-time just started to pop off. There are two main variables which will be focused on, tensor and variable in PyTorch. Tensor is used to define an n-dimension matrix or multi-dimensional ... Read More

Difference between str.capitalize() vs str.title()

Jaisshree
Updated on 10-Aug-2023 14:30:27

191 Views

In Python, String is a sequence of characters surrounded by either double quotes(" ") or single quotes (' '). Strings are used to represent text data in Python and it can contain letters, numbers, and symbols. String data type is immutable in Python, that is once a string instance is created it's value cannot be changed. But a new string with the required changes made in the original string can be created. Python Strings come with numerous methods like capitalize(), upper(), title(), split(), strip(), join(), etc. that can also be used to manipulate strings. str.capitalize() ... Read More

Difference between Spark Dataframe and Pandas Dataframe

Jaisshree
Updated on 10-Aug-2023 14:24:20

572 Views

Spark DataFrame Spark DataFrame is a distributed data collection established into named columns. it's a key statistics structure in Apache Spark, a quick and distributed computing device optimised for huge data processing. In a distributed computing context, Spark DataFrames provide a better-stage API for operating with established and semi-structured information. Pandas DataFrame A Pandas DataFrame is a two-dimensional labelled data structure that represents tabular data. It is one of the core data structures provided by the Pandas library in Python. The DataFrame organizes data in a row-column format, similar to a table or spreadsheet. Advantages ... Read More

Difference between Shallow Copy vs Deep Copy in Pandas Dataframe

Jaisshree
Updated on 10-Aug-2023 14:45:59

182 Views

One of the most useful data structures in Pandas is the Pandas DataFrame which is a 2-Dimensional table-like structure that contains rows and columns to store data. It allows users to store and manipulate the data, very similar to a spreadsheet or SQL table. It also provides a serial or linear data structure which is called the 1-Dimensional labelled array that can hold elements of any data type. Shallow Copy A shallow copy, as the name suggests, creates a new DataFrame object that references the original data. In other words, a shallow copy points to the ... Read More

Sort the string as per the ASCII values of the characters

Disha Gupta
Updated on 22-Jan-2024 17:39:06

1K+ Views

ASCII Values ASCII (American Standard Code for Information Interchange) is the most common character encoding format for text data in computers and on the internet. In standard ASCII-encoded data, there are unique values for 256 alphabetic, numeric, or special additional characters and control codes. Problem Statement Now, in this problem, we need to find the sorted string as per ASCII values of the characters in increasing order, where the string will be the input given to us by the user. Let us see how we should proceed to solve this problem. Let’s try to understand this problem with the help ... Read More

Minimize hamming distance in Binary String by setting only one K size substring bits

Disha Gupta
Updated on 22-Jan-2024 13:18:23

94 Views

Hamming distance between two strings of equal length is the number of all the positions at which a different value exists at the corresponding position of the other string. We can understand this with an example given below − S = “ramanisgoing” T = “dishaisgoing” Here, 5 is the hamming distance between two strings S and T as raman and disha are two words that make a difference in the strings to become equal. Problem Statement However, in this problem, we need to find the hamming distance between two strings that contain binary numbers only. One string would be ... Read More

The maximum length of string formed by concatenation having an even frequency of each character

Disha Gupta
Updated on 05-Feb-2024 18:11:07

53 Views

Concatenation is an operator which is used to join one or more than one string to originate a new string which would be a combination of strings that were used to generate it with the help of concatenation. In the following article, we will take the uppercase letters only in the input string. Concatenation is an operator which is used to join one or more than one string to originate a new string which would be a combination of strings that were used to generate it with the help of concatenation. In the following article, we will take the uppercase ... Read More

Difference between Shallow and Deep Copy of a Class

Jaisshree
Updated on 10-Aug-2023 14:20:39

409 Views

A class is a blueprint or template that defines objects' attributes (data) and behaviours (methods). It's by far a fundamental concept of object-orientated programming (OOP) that allows you to create items based totally on the class definition. Shallow copy Shallow copy creates a new object that stores the reference of the original elements. Instead of making a duplicate of the nested objects, it just replicates their references. This means that a copy process does not recurse or create copies of nested objects itself. Shallow copy is faster than deep copy, but it is "lazy" and handles pointers and ... Read More

Maximize the String value by assigning values in the range [1, 26] to each character

Disha Gupta
Updated on 05-Feb-2024 18:14:07

152 Views

There are 26 total different alphabets exist in the English language. If we want to change the alphabet characters into numerical values then we need to assign the alphabet, values between 1 to 26 only. Now, in this problem, we need to Maximize the String value by assigning values in the range [1, 26] to each character. Let us see how we should proceed to solve this problem. Let’s try to understand this problem with the help of some examples. Input s = “blpsBpPtT” Output 221 Explanation Here, in this ... Read More

Difference between reshape() and resize() method in Numpy

Jaisshree
Updated on 10-Aug-2023 14:15:41

318 Views

The size of the NumPy arrays can be changed with the help of two functions in python namely reshape and resize. There's only one thing that differentiates them, the original array remains unchanged while using resize() while reshape() returns only the changed array and the original array remains intact. Syntax Reshape() reshape(x, y) In this syntax, x specifies the number of smaller arrays that has to be created from the larger array provided as input and y denotes the actual number of elements present in the array. The method returns a modified array if the ... Read More

Advertisements