Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 114 of 2109
How to Run Python Flask App Online using Ngrok?
Ngrok is a tool that creates a secure tunnel between your local machine and the internet. It allows developers to expose their local web server to the internet without deploying it to a remote server. Python Flask lets you create web applications locally, but with Ngrok, you can showcase them online instantly. Step 1: Install Ngrok Download Ngrok from its official website (https://ngrok.com/download) for your operating system (Windows/macOS/Linux). Extract the archive to your preferred folder location. Step 2: Create a Flask App Create a new Python file called app.py with a simple Flask application ? ...
Read MoreHow to run multiple Python files in a folder one after another?
The subprocess module can be used to run multiple Python files in a folder one after another. Running multiple files sequentially is required in various situations like processing large datasets, performing complex analysis, or automating workflows. In this article, we will discuss different methods for running multiple Python files in a folder sequentially with practical examples. Method 1: Using subprocess Module The subprocess module provides a powerful way to spawn new processes and run external commands. Here's how to use it for running Python files sequentially ? Step 1: Create Sample Python Files First, let's create ...
Read MoreHow to rotate the X label using Pygal?
Pygal is a Python library that is used to create interactive, customizable charts and graphs. We can rotate the x-axis label using the x_label_rotation attribute in the Pygal module. The rotation of the x-axis label makes the chart easier to read and comprehend when dealing with long labels or limited space. Algorithm A general algorithm for rotating the x label using pygal is given below − Import the Pygal module. Create a chart object (e.g., Bar, Line, Pie, etc.). Add data to the chart ...
Read MoreHow to Retrieve an Entire Row or Column of an Array in Python?
Python provides various methods to retrieve entire rows or columns from arrays. We can use slice notation, NumPy functions, list comprehension, and for loops. In this article, we'll explore all these methods with practical examples. Using Slice Notation Slice notation extracts subsets of elements using the : notation. To retrieve entire rows or columns, we specify : for the dimension we want completely ? Syntax array_name[row_index, column_index] # For entire row: array_name[row_index, :] # For entire column: array_name[:, column_index] Example Here we create a 2D array and retrieve the second ...
Read MoreHow to reshape Pandas Series?
A Pandas Series is a one-dimensional labeled array that can hold various data types. Reshaping a Series means changing its structure or format to suit different analysis needs. Python provides several methods to reshape Series data including transpose, reshape, melt, and pivot operations. Using the Transpose Attribute (.T) The transpose attribute switches rows and columns. For a Series, this operation doesn't change much since it's already one-dimensional ? import pandas as pd # Create a Series series = pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd']) print("Original Series:") print(series) # Transpose the Series series_transposed ...
Read MoreHow To Track ISS (International Space Station) Using Python?
Tracking the International Space Station (ISS) in real-time is an exciting project that combines space exploration with Python programming. This article demonstrates how to fetch ISS location data using APIs and visualize it on an interactive map using the folium library. Installing Required Libraries Before we start tracking the ISS, we need to install two essential libraries: requests for making API calls and folium for creating interactive maps. pip install requests folium Fetching ISS Location Data The Open Notify API provides real-time ISS location data in JSON format. Let's create a function to ...
Read MoreHow to test Typing Speed using Python?
Creating a typing speed test in Python is a fun way to measure and improve your typing skills. This tutorial will show you how to build a simple program that measures your words per minute (WPM) and accuracy. Required Modules We need two built-in Python modules for our typing speed test ? import time import random Setting Up Test Sentences First, let's create a list of sentences to type during the test ? sentences = [ "The quick brown fox jumps over the lazy dog.", ...
Read MoreHow to Terminate a Running Process on Windows in Python?
When working with Python on Windows, you may need to terminate running processes due to unresponsiveness, high resource usage, or to stop script execution. Python provides several methods to accomplish this task using the os module, psutil library, and subprocess module. Using the os Module The os module allows you to execute operating system commands. On Windows, you can use the taskkill command to terminate processes ? import os # The process name to terminate process_name = "notepad.exe" # Using taskkill command to terminate the process result = os.system(f"taskkill /f /im {process_name}") if ...
Read MoreHow to take backups of MySQL databases using Python?
Backing up MySQL databases is crucial for data protection. Python provides several approaches using the subprocess module to execute the mysqldump command-line utility for creating reliable database backups. Using subprocess Module The subprocess module allows you to execute system commands from Python. We can use it to run mysqldump and create database backups ? import subprocess # Define database connection details host = "localhost" user = "username" password = "password" database = "database_name" backup_file = "backup.sql" # Execute the mysqldump command command = f"mysqldump -h{host} -u{user} -p{password} {database} > {backup_file}" subprocess.run(command, shell=True) ...
Read MoreHow to Replace Values in Columns Based on Condition in Pandas
In Python, we can replace values in columns based on conditions in Pandas using various built-in functions like loc, where and mask, apply and lambda, map, and numpy.where. Pandas is a powerful library for data manipulation and working with structured data. This article demonstrates five different methods to conditionally replace column values. Using loc The loc function allows you to access and modify specific rows and columns in a DataFrame based on boolean conditions ? Syntax df.loc[row_condition, column_labels] = new_value Example Let's replace the gender of people aged 50 or older with ...
Read More