Found 34494 Articles for Programming

Centered Heptagonal Number

Simran Kumari
Updated on 23-Aug-2023 09:50:57

95 Views

What do you understand by the term centered hepatgonal number? Let’s decode in this article. First of all, what is a heptagonal number? A heptagonal number is a figurate number representing the number of dots that can be arranged to form a regular heptagon (a seven−sided polygon). The formula for the nth heptagonal number is: n(5n−3)/2, where n must be a positive integer. The first few heptagonal numbers, for example, are: 1 is the first heptagonal number (corresponding to a heptagon with one dot). 7 is the second heptagonal number (corresponding to a heptagon with 7 dots). 18 is ... Read More

Cake Number

Simran Kumari
Updated on 23-Aug-2023 09:48:40

129 Views

What do you understand by the term `Cake Number`? Let's decode it in this article. The term "cake number" describes a concept of discrete geometry and combinatorics−related mathematical idea. It is built on the concept of the Lazy caterer's sequence. What is the Lazy Caterer's Sequence? The maximum number of pieces a disk (cake or pizza) can be sliced into using a specific number of straight slices is known as the Lazy caterer's sequence. Although it mentions a disk, we will consider a cake in our example. One straight cut can divide a cake into two pieces, two straight cuts ... Read More

Fromisoformat() Function of Datetime.date Class in Python

Jaisshree
Updated on 23-Aug-2023 09:46:27

793 Views

The datetime.date class in Python provides a convenient way to represent and manipulate dates. The fromisoformat() method lets in you to create a date object from a string in the ISO layout. The fromisoformat() feature will parse a string in ISO 8601 format and create a date object that represents that date. this could be beneficial in numerous scenarios, consisting of whilst you want to parse dates from log files or whilst working with APIs that offer dates in ISO 8601 format. Syntax datetime.date.fromisoformat(date_string) The parameter, date_string is a string that represents a date in the ISO format ... Read More

Finding the Number of Weekdays of a Given Month in NumPy

Jaisshree
Updated on 23-Aug-2023 09:18:04

140 Views

Numpy is an open-source library in Python used for numerical computing, scientific computing, data analysis, and machine learning applications. This library has powerful array methods and tools to perform vector and matrix operations. You must install the NumPy module manually since it is not a component of the default Python library. The Python package manager pip can be used to accomplish this by executing the following command − pip install numpy We will use NumPy’s busday_count() function to calculate the required count of weekdays. This will calculate the number of business days (Monday to Friday) between 2 specific dates. ... Read More

Find the size of numpy Array

Jaisshree
Updated on 23-Aug-2023 09:15:27

237 Views

Numpy is often used along with packages such as SciPy and matplotlib in python. Additionally, arrays in Numpy are faster compared to lists in Python due to which this module is extensively used for complex mathematical algorithms and problems. It has various functions, and methods, to make our task easy and simple for matrix operations. In Numpy arrays there are two types of array − Single Dimensional Array Multi-Dimensional Array Single Dimensional Array (1D array) The datatypes of the elements stored in the array are - strings, integers, boolean or floating points. These arrays are called single or ... Read More

Find the path to the given file in Python

Jaisshree
Updated on 23-Aug-2023 09:13:13

1K+ Views

Python users frequently work with files, particularly when altering, reading, or writing data to files. However, identifying a file's path is necessary before performing any operation on it. Simply said, a file's path refers to the system location or directory where it is kept. There are four major types of methods to use to find the path to the given file in Python − Pathlib Module OS Module os.path.join() method os.getcwd() method Approach 1: Using the Pathlib Module The pathlib module in Python makes everything very feasible and efficient to make file paths. absolute() − An absolute path ... Read More

Find the maximum and minimum element in a NumPy array

Jaisshree
Updated on 23-Aug-2023 09:09:43

813 Views

The well-known open-source Python library NumPy is used for numerical computing. Large, multi-dimensional arrays and matrices are supported, along with a sizable number of sophisticated mathematical operations that can be used to work effectively on these arrays. When working with NumPy arrays, finding the maximum and minimum elements is often necessary. Method 1:Using max() and min() Functions The following code demonstrates creating an array of integers. We then use the max() and min() functions to find the highest and lowest value elements in the array, respectively. Algorithm Import the desired Numpy library. Create a 1D numpy array with integer ... Read More

Finding how much memory is being used by an object in Python

Jaisshree
Updated on 23-Aug-2023 09:08:06

1K+ Views

Memory is frequently set up in a computer system as a series of binary digits, or bits. Each byte is given a unique memory location that may be used to read from or write to the byte's value. Bytes, which can be interpreted as characters, integers, floating-point numbers, or other data kinds, are used to store data in memory. You may measure memory use in Python with the aid of tools like the built-in sys.getsizeof() and asizeof() from pympler. Method 1: Using Getsizeof() Function The amount of memory required by an object or data structure may be ascertained with ... Read More

Fillna in Multiple Columns in Place in Python Pandas

Jaisshree
Updated on 23-Aug-2023 09:05:14

2K+ Views

Python has an open-source built-in library called Pandas for data analysis and manipulation. It has a well-defined data structure called DataFrame, similar to a table. It can also be used for writing and reading data from various types of files like CSV, Excel, SQL databases, etc. fillna() is a method which is used to fill missing (NaN/Null) values in a Pandas DataFrame or Series. The missing values are filled with a definite value or another specified method along with the method call. Syntax object_name.fillna(value, method, limit, axis, inplace, downcast) The fillna() method returns the same input DataFrame or Series ... Read More

Filling area chart using plotly in Python

Jaisshree
Updated on 23-Aug-2023 09:02:55

264 Views

Plotly is a library in Python which is very useful in plotting various kinds of graphs and charts. It is an interactive visualization library used to create quality graphs for publications. Somes of the graphs and charts that can be visualized with plotly include line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts, and bubble charts. Filled Area Chart Filled area plot is an enhanced module in plotly that analyzes a variety of data and produces user friendly figures that are easily readable. The filled area harmonizes with a particular value ... Read More

Advertisements