Programming Articles

Page 68 of 2547

How to check for a substring in a PySpark dataframe?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 4K+ Views

PySpark is a Python library that provides an interface to Apache Spark, a distributed computing system for processing large datasets. PySpark allows you to write Spark applications using Python, making it accessible for Python developers to work with big data. What is Substring Checking in PySpark? Substring checking in PySpark DataFrames involves searching for specific patterns or text within column values. This is commonly used for data filtering, pattern matching, and text analysis operations. PySpark provides several built-in functions to perform substring operations efficiently across distributed datasets. Setting Up PySpark First, let's create a sample DataFrame ...

Read More

How to check horoscope using Python?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 362 Views

Python can be used to create a horoscope checker by web scraping horoscope websites. This tutorial shows how to fetch daily horoscope predictions using BeautifulSoup and the requests library. Installing Required Packages First, install the required packages − pip install beautifulsoup4 requests The output shows successful installation − Collecting beautifulsoup4 Downloading beautifulsoup4-4.12.2.tar.gz (520 kB) Successfully installed beautifulsoup4-4.12.2 requests-2.31.0 Basic Horoscope Checker Here's a simple script to fetch horoscope predictions − import requests from bs4 import BeautifulSoup # Zodiac signs mapped to their numeric IDs ...

Read More

How to check if the PyMongo Cursor is Empty?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 2K+ Views

PyMongo is a Python library that provides a way to interact with MongoDB, the popular NoSQL document-oriented database. It allows developers to easily connect to MongoDB instances and perform operations like inserting, retrieving, and querying documents. Understanding PyMongo Cursors A cursor in MongoDB is an object that points to query results. When you execute the find() method, the results are returned as a cursor object. You can iterate through this cursor to access the documents in the result set. In PyMongo, the cursor is represented by the Cursor class. This object contains the results of your search ...

Read More

How to check whether user\'s internet is on or off using Python?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 14K+ Views

When building Python applications, you often need to verify whether the user's system has an active internet connection. This can be accomplished through several approaches: sending HTTP requests, establishing socket connections, or using system ping commands. Using requests.get() Method The requests module provides a simple way to send HTTP requests. By attempting to connect to a reliable website, we can determine internet connectivity ? Syntax requests.get(url, timeout=seconds) Where url is the website URL and timeout is the maximum waiting time for a response. Example import requests def check_internet_requests(): ...

Read More

How to click a href link from bootstrap tabs using Python?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 314 Views

Bootstrap is a popular HTML, CSS, and JavaScript framework for developing responsive web applications. When working with Bootstrap tabs, you may need to programmatically click href links within tab components. Python's Selenium library provides the perfect solution for automating such interactions. The Selenium Library Selenium is an open-source automation testing tool that allows you to control web browsers programmatically. It's primarily used for automated testing of web applications but is also valuable for web scraping and automating repetitive browser tasks. Selenium supports multiple programming languages including Python, Java, C#, and Ruby, and works with browsers like Chrome, Firefox, ...

Read More

How to clone webpage using pywebcopy in python?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 2K+ Views

Python provides the pywebcopy module that allows us to download and store entire websites including all images, HTML pages, and other files to our local machine. The save_webpage() function is the primary method for cloning webpages. Installing pywebcopy Module First, install the pywebcopy module using pip ? pip install pywebcopy On successful installation, you will get output similar to this ? Looking in indexes: https://pypi.org/simple Collecting pywebcopy Downloading pywebcopy-7.0.2-py2.py3-none-any.whl (46 kB) Installing collected packages: pywebcopy Successfully installed pywebcopy-7.0.2 Syntax The basic syntax for using the save_webpage() function ...

Read More

How to communicate JSON data between Python and Node.js?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 741 Views

JSON (JavaScript Object Notation) is a lightweight text-based format for transferring and storing data between different programming languages. Python provides built-in JSON support through the json module, while Node.js has native JSON parsing capabilities. To communicate JSON data between Python and Node.js, we typically use HTTP requests where one service acts as a server and the other as a client. This enables seamless data exchange between the two platforms. Installing Required Dependencies For Python, install Flask to create a web server: pip install flask requests For Node.js, install the request-promise module: ...

Read More

Synsets for a word in WordNet in NLP

Mithilesh Pradhan
Mithilesh Pradhan
Updated on 27-Mar-2026 1K+ Views

WordNet is a large lexical database available in the NLTK library that organizes words by their semantic relationships. It provides an interface called Synsets (synonym sets) that groups semantically similar words together, making it valuable for Natural Language Processing tasks. WordNet Structure and Synsets Animal Mammal Bird Dog Cat Eagle ...

Read More

How to choose elements from the list with different probability using NumPy?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 1K+ Views

NumPy provides several methods to randomly choose elements from a list with different probabilities. The probability values must sum to 1.0. Here are three main approaches using NumPy's random module. Using numpy.random.choice() The choice() function randomly samples elements from a 1-D array with specified probabilities ? Syntax numpy.random.choice(a, size=None, replace=True, p=None) Parameters: a − Input array or list of elements size − Output shape (optional) replace − Whether sampling is with replacement (default: True) p − Probabilities for each element (must sum to 1) Example 1: 1-D Array ...

Read More

How to check whether the element of a given NumPy array is non-zero?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 370 Views

NumPy provides several methods to check whether elements in an array are non-zero. Each approach serves different purposes: checking if all elements are non-zero, finding indices of non-zero elements, or counting non-zero elements. Using np.all() for Boolean Check The np.all() function checks if all elements in an array are non-zero (truthy). It returns True if all elements are non-zero, False otherwise ? import numpy as np arr = np.array([2, 5, 8, 11, 14, 17]) print("Original array:", arr) if np.all(arr): print("All elements are non-zero") else: print("Array contains ...

Read More
Showing 671–680 of 25,466 articles
« Prev 1 66 67 68 69 70 2547 Next »
Advertisements