Vani Nalliappan

Vani Nalliappan

122 Articles Published

Articles by Vani Nalliappan

Page 3 of 13

How to change the size of a Dash Graph in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 3K+ Views

Dash is a Python framework for building interactive web applications with Plotly graphs. You can easily control the size of graphs in a Dash app by using the style parameter in dcc.Graph() component to set custom height and width dimensions. Basic Setup First, import the required libraries and create sample data ? import dash from dash import dcc, html import pandas as pd import plotly.express as px # Create sample data df_bar = pd.DataFrame({ "Season": ["Summer", "Winter", "Autumn", "Spring"], "Rating": [3, 2, 1, 4] }) # ...

Read More

How to set the range of Y-axis in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 30K+ Views

Plotly is a powerful Python library for creating interactive visualizations. One common requirement is controlling the Y-axis range to better display your data or focus on specific value ranges. Setting Y-axis Range with update_layout() The most straightforward way to set the Y-axis range is using the update_layout() method with the yaxis_range parameter − import plotly.graph_objs as go import numpy as np # Set random seed for reproducible results np.random.seed(3) # Generate X-axis data (0 to 18, step 2) x_values = list(range(0, 20, 2)) # Generate random Y-axis data y_values = np.random.randn(10) # ...

Read More

How to set the line color in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 17K+ Views

Python Plotly provides several methods to customize line colors in graphs. In this tutorial, we'll explore how to set line colors using plotly.express and the update_traces() method. Plotly Express contains many methods to customize charts and render them in HTML format. The update_traces() method with the line_color parameter is the primary way to set line colors after creating a plot. Basic Line Color Setting Here's a complete example showing how to create a line plot and set its color ? import plotly.express as px import pandas as pd # Create sample data data = ...

Read More

How to plot multiple figures as subplots in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 13K+ Views

Plotly is an open-source Python library for creating interactive charts. You can use the make_subplots feature available in Plotly to combine multiple figures into subplots within a single layout. In this tutorial, we will use plotly.graph_objects and plotly.subplots to create multiple subplots. The make_subplots() function allows you to specify the grid layout, while append_trace() adds individual plots to specific positions. Basic Subplot Creation Here's how to create a simple subplot layout with three scatter plots ? from plotly.subplots import make_subplots import plotly.graph_objects as go # Create subplot grid: 3 rows, 1 column fig = ...

Read More

How to open a URL by clicking a data point in Python Plotly?

Vani Nalliappan
Vani Nalliappan
Updated on 26-Mar-2026 3K+ Views

In Python Plotly with Dash, you can create interactive scatter plots where clicking a data point opens a specific URL. This is achieved by storing URLs as custom data and using Dash callbacks to handle click events. Setting Up the Dashboard First, import the required libraries and create a Dash application − import webbrowser import dash from dash.exceptions import PreventUpdate from dash import dcc, html from dash.dependencies import Input, Output import plotly.express as px import pandas as pd # Create Dash app app = dash.Dash(__name__) Creating Data with URLs Create a DataFrame ...

Read More

Python Pandas – How to use Pandas DataFrame tail( ) function

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 734 Views

The Pandas DataFrame tail() function returns the last n rows of a DataFrame. This is particularly useful when combined with filtering operations to examine the bottom portion of your filtered data. Syntax DataFrame.tail(n=5) Parameters: n (int, optional): Number of rows to select. Default is 5. Creating Sample Data Let's create a sample dataset to demonstrate the tail() function ? import pandas as pd # Create sample products data data = { 'id': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ...

Read More

Python Pandas – How to use Pandas DataFrame Property: shape

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 1K+ Views

The shape property in Pandas DataFrame returns a tuple containing the number of rows and columns. It's essential for understanding your dataset dimensions before performing data analysis operations. DataFrame.shape Property The shape property returns (rows, columns) as a tuple. You can access individual values using indexing ? # Basic syntax df.shape # Returns (rows, columns) df.shape[0] # Number of rows df.shape[1] # Number of columns Creating Sample Data Let's create a sample products dataset to demonstrate the shape ...

Read More

Python Pandas - Read data from a CSV file and print the 'product' column value that matches 'Car' for the first ten rows

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 1K+ Views

When working with CSV data in Pandas, you often need to filter specific rows based on column values. This tutorial shows how to read a CSV file and filter rows where the 'product' column matches 'Car' from the first ten rows. We'll use the 'products.csv' file which contains 100 rows and 8 columns with product information. Sample Data Structure The products.csv file contains the following structure ? Rows: 100 Columns: 8 id product engine avgmileage price height_mm width_mm productionYear 1 2 ...

Read More

Write a program in Python to verify camel case string from the user, split camel cases, and store them in a new series

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 913 Views

Camel case is a naming convention where the first letter is lowercase and each subsequent word starts with an uppercase letter (e.g., "pandasSeriesDataFrame"). This tutorial shows how to verify if a string is in camel case format and split it into a pandas Series. Understanding Camel Case Validation A valid camel case string must satisfy these conditions: Not all lowercase Not all uppercase Contains no underscores Solution Steps To solve this problem, we follow these steps: Define a function that accepts the input string Check if the string is in camel ...

Read More

Write a Python code to combine two given series and convert it to a dataframe

Vani Nalliappan
Vani Nalliappan
Updated on 25-Mar-2026 302 Views

When working with Pandas Series, you often need to combine them into a single DataFrame for analysis. Python provides several methods to achieve this: direct DataFrame creation, concatenation, and joining. Method 1: Using DataFrame Constructor Create a DataFrame from the first series, then add the second series as a new column ? import pandas as pd series1 = pd.Series([1, 2, 3, 4, 5], name='Id') series2 = pd.Series([12, 13, 12, 14, 15], name='Age') df = pd.DataFrame(series1) df['Age'] = series2 print(df) Id Age 0 1 ...

Read More
Showing 21–30 of 122 articles
« Prev 1 2 3 4 5 13 Next »
Advertisements