Found 10784 Articles for Python

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

812 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

262 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

File Sharing App using Python

Jaisshree
Updated on 23-Aug-2023 09:00:47

810 Views

Bluetooth and WhatsApp are often used to send files from one device to another. Although both these methods are quite convenient, having a simple QR Code to tap into other devices’ documents is satisfyingly fun. Especially, when this can be done in minutes using Python. With the help of Python combined with the concepts of computer networks, we can make a simple python application to share documents over different devices. This application will provide both an IP address as well as a QR Code. As required, you can scan the code or type in the IP address in the device ... Read More

File Explorer IN Python Using Tkinter

Jaisshree
Updated on 23-Aug-2023 08:58:05

2K+ Views

Tkinter is a Python toolkit library used to build interfaces, design applications and create Graphical User Interfaces (GUIs). It originated from the Tcl programming language, which Python uses as a wrapper around Tk GUI Toolkit. Now it is used mostly with Python. It is a versatile tool where you can develop pages, buttons and customize fonts and background colours according to your preference. A file explorer is a tool that allows the user to navigate through all existing files present in the system for ease of access to files and open them without much difficulty. It offers a centralized database, ... Read More

Fidget Spinner Using Python

Jaisshree
Updated on 23-Aug-2023 08:56:52

359 Views

Fidget Spinner is one of the fun and interesting projects that can be made possible using existing Python modules. A fidget spinner is a device that remains stationary in one place and keeps spinning as long as the person flicks it constantly, or else it will stop spinning completely. To simulate this, we can use libraries like pygame which provides us with an interface which can be customized to our liking while building games in general. There is also another such library which will be used for running the fidget spinner, similar to its real-life counterpart. Installation and Syntax To ... Read More

Element Methods in Selenium Python

Jaisshree
Updated on 23-Aug-2023 08:55:35

370 Views

Selenium, an open source automation testing tool is used with other programming scripts like python , java , javascript and pearl to test web applications. It is widely used by developers for automation testing. Element Methods of Selenium 1. send_keys () − Used for setting up input text boxes which includes edit box, text area, fields inside forms and modifier keys. It extends properties from the keys class. Return Type − null 2. is_selected() − Checks if an element is selected or not by the user Return Type − boolean value ( True or False). 3. is_displayed() − Checks ... Read More

Generate a list using given frequency list

Atharva Shah
Updated on 22-Aug-2023 18:19:07

166 Views

Generating a list using a given frequency list is a common problem in programming. The task involves creating a list of elements based on the frequency distribution of those elements. This can be useful in many scenarios, such as generating a password with a specific character distribution or generating random sentences with specific word frequencies. In this article, we will explore how to generate a list using a given frequency list in Python. Installation and Syntax Python is a popular programming language for analyzing and modifying data, and it provides the Counter module from the collections package to make a ... Read More

Advertisements