Articles on Trending Technologies

Technical articles with clear explanations and examples

Explain the use of MIN() and MAX() using MySQL in Python?

Pawandeep Kaur
Pawandeep Kaur
Updated on 25-Mar-2026 1K+ Views

The MIN() and MAX() functions are MySQL aggregate functions used to find the smallest and largest values from a selected column. In Python, we can execute these functions through MySQL connector to perform database operations. The MIN() function returns the smallest value from the selected column, while the MAX() function returns the largest value from the selected column. Syntax MIN() Function: SELECT MIN(column_name) FROM table_name MAX() Function: SELECT MAX(column_name) FROM table_name Steps to Find Minimum and Maximum Values To execute MIN() and MAX() functions using MySQL in Python, ...

Read More

How can you perform inner join on two tables using MySQL in Python?

Pawandeep Kaur
Pawandeep Kaur
Updated on 25-Mar-2026 3K+ Views

We can join two tables in SQL based on a common column between them or based on some specified condition. There are different types of JOIN available to join two SQL tables. Here, we will discuss about the inner join on two tables using MySQL in Python. JOIN and INNER JOIN both work the same way. The INNER JOIN matches each row in one table with every row in other table and allows to combine the rows from both the tables which either have some common column or which satisfy some condition which is specified. When applying ...

Read More

How can you avoid getting an error if you are deleting a table which does not exist using Python?

Pawandeep Kaur
Pawandeep Kaur
Updated on 25-Mar-2026 718 Views

When deleting database tables in Python, you might encounter errors if the table doesn't exist. This can happen when you mistype the table name or when another user has already deleted the table. Using the IF EXISTS clause prevents these errors by checking table existence before deletion. Syntax DROP TABLE IF EXISTS table_name This statement performs the drop operation only if the table exists, preventing errors when the table is not found. Steps to Delete a Table Safely Import MySQL connector Establish connection using connect() Create cursor object using cursor() method Create ...

Read More

Explain the use of SELECT DISTINCT statement in MySQL using Python?

Pawandeep Kaur
Pawandeep Kaur
Updated on 25-Mar-2026 1K+ Views

MySQL tables often contain duplicate values in columns. The SELECT DISTINCT statement helps retrieve only unique values, making data analysis easier and results cleaner. For example, if you have a customers table with multiple customers from the same countries, using SELECT DISTINCT on the country column returns only the unique country names instead of all duplicate entries. Syntax SELECT DISTINCT column_name FROM table_name Steps to Use SELECT DISTINCT in Python Import the MySQL connector Establish database connection using connect() Create a cursor object using cursor() method Write the SELECT DISTINCT query Execute ...

Read More

How can you retrieve a particular number of records from a table starting from some specified row number in Python MySQL?

Pawandeep Kaur
Pawandeep Kaur
Updated on 25-Mar-2026 1K+ Views

Most frequently, we do not require to select all the rows from a table. We may at times need to retrieve a particular number of records from a table, starting from some specific index. Suppose, we have a table of 10 records. We need to select 5 rows from the table starting from 3rd row. This is done using the LIMIT and OFFSET clause along with the SELECT statement. The LIMIT is used to specify the number of rows that you want to retrieve. The OFFSET is used to specify the starting position from where the rows are to ...

Read More

What is the fetchone() method? Explain its use in MySQL Python?

Pawandeep Kaur
Pawandeep Kaur
Updated on 25-Mar-2026 9K+ Views

The fetchone() method in MySQL Python is used to retrieve only the first row from a query result. It returns a single tuple representing one row from the database table. What is fetchone()? The fetchone() method is called on a cursor object after executing a SELECT query. Unlike fetchall() which retrieves all rows, fetchone() returns only the first row as a tuple. If no rows are found, it returns None. Syntax cursor.fetchone() How fetchone() Works The process involves these steps: Execute a SELECT query using cursor.execute() The cursor object holds ...

Read More

How to customize X-axis ticks in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 4K+ Views

To customize X-axis ticks in Matplotlib, you can modify their appearance including length, width, color, and direction using the tick_params() method. Basic X-axis Tick Customization Let's start with a simple bar chart and customize the X-axis ticks ? import numpy as np import matplotlib.pyplot as plt # Set figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Sample data height = [3, 12, 5, 18, 45] bars = ('A', 'B', 'C', 'D', 'E') y_pos = np.arange(len(bars)) # Create bar plot plt.bar(y_pos, height, color='yellow') # Customize X-axis ticks plt.tick_params(axis='x', colors='red', direction='out', length=7, ...

Read More

How to remove grid lines from an image in Python Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 7K+ Views

To remove grid lines from an image in Python Matplotlib, you need to explicitly disable the grid using grid(False). By default, Matplotlib may show grid lines over images, which can interfere with image visualization. Steps to Remove Grid Lines Set the figure size and adjust the padding between and around the subplots Load an image from a file Convert the image from one color space to another if needed To remove grid lines, use ax.grid(False) or plt.grid(False) Display the data as an image using imshow() Display the figure using show() method Example Here's how ...

Read More

How to save a plot in Seaborn with Python (Matplotlib)?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 4K+ Views

To save a plot in Seaborn, we can use the savefig() method from Matplotlib. Since Seaborn is built on top of Matplotlib, we can save any Seaborn plot using this approach. Basic Syntax import matplotlib.pyplot as plt # Create your Seaborn plot # Then save it plt.savefig('filename.png') Example: Saving a Pairplot Let's create a pairplot and save it to a file − import seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt # Set figure parameters plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True ...

Read More

Create a legend with Pandas and Matplotlib.pyplot

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 1K+ Views

To create a legend with Pandas and matplotlib.pyplot, we can plot DataFrame data and enable the legend parameter. The legend helps identify different data series in the plot. Steps to Create a Legend Set the figure size and adjust the padding between and around the subplots. Create a DataFrame with multiple columns for plotting. Plot the DataFrame using plot() method with legend=True. Display the figure using show() method. Example Let's create a bar chart with a legend showing two data series ? import pandas as pd from matplotlib import pyplot as plt ...

Read More
Showing 4321–4330 of 61,297 articles
« Prev 1 431 432 433 434 435 6130 Next »
Advertisements