Server Side Programming Articles

Page 431 of 2109

How can Tensorflow be used to visualize training results using Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 978 Views

TensorFlow training results can be effectively visualized using Python with the matplotlib library. This visualization helps identify training patterns, overfitting, and model performance trends during the training process. Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks? We will use the Keras Sequential API, which is helpful in building a sequential model that works with a plain stack of layers, where every layer has exactly one input tensor and one output tensor. A neural network that contains at least one convolutional layer is known as a Convolutional Neural Network (CNN). We ...

Read More

Write a Python function to split the string based on delimiter and convert to series

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

When working with strings in Python, you often need to split them based on a delimiter and convert the result into a Pandas Series for further data analysis. This is commonly done when processing CSV-like data or text files. Understanding the Problem Let's say we have a tab-separated string like 'apple\torange\tmango\tkiwi' and want to split it into individual elements, then convert to a Pandas Series ? 0 apple 1 orange 2 mango 3 kiwi dtype: object Method 1: Using a Function ...

Read More

Write a program in Python to print the first and last three days from a given time series data

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

When working with time series data in Pandas, you often need to extract specific time periods. The first() and last() methods allow you to retrieve data from the beginning and end of a time series based on a time offset. Creating Time Series Data First, let's create a time series with city names indexed by dates ? import pandas as pd # Create a series with city names data = pd.Series(['Chennai', 'Delhi', 'Mumbai', 'Pune', 'Kolkata']) # Create a date range with 2-day frequency time_series = pd.date_range('2020-01-01', periods=5, freq='2D') # Set the date range ...

Read More

Write a program in Python to generate a random array of 30 elements from 1 to 100 and calculate maximum by minimum of each row in a dataframe

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

In this tutorial, we'll learn how to generate a random array of 30 elements from 1 to 100, reshape it into a DataFrame, and calculate the ratio of maximum to minimum values for each row. Understanding the Problem We need to create a 6×5 DataFrame with random integers and calculate max/min ratio for each row using pandas operations. Solution Approach Follow these steps to solve the problem − Generate 30 random integers from 1 to 100 using np.random.randint() Reshape the array to (6, 5) to create a 2D structure Convert to DataFrame and apply ...

Read More

Write a program in Python to find which column has the minimum number of missing values in a given dataframe

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

When working with data analysis, it's common to encounter missing values in DataFrames. Sometimes you need to identify which column has the minimum number of missing values to help guide your data cleaning strategy. Problem Statement Given a DataFrame with missing values, we need to find which column has the fewest NaN values. This is useful for determining which columns are most complete in your dataset. Sample DataFrame Let's start by creating a sample DataFrame with missing values to demonstrate the solution ? import pandas as pd import numpy as np df = ...

Read More

Write a Python function to calculate the total number of business days from a range of start and end date

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

Business days are weekdays (Monday through Friday), excluding weekends and holidays. Python's Pandas library provides several methods to calculate business days between two dates. Understanding Business Days First, let's see what business days look like in a date range ? import pandas as pd dates = pd.bdate_range('2020-01-01', '2020-01-31') print("Business days in January 2020:") print(dates) print(f"Total business days: {len(dates)}") Business days in January 2020: DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-06', '2020-01-07', '2020-01-08', '2020-01-09', '2020-01-10', ...

Read More

Write a program in Python to perform flatten the records in a given dataframe by C and F order

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

When working with DataFrames, you may need to flatten the data into a one-dimensional array. Python Pandas provides the ravel() function which can flatten data in different orders: C order (row-major) and F order (column-major). Understanding C and F Order The order parameter determines how multi-dimensional data is flattened ? C order (row-major): Flattens row by row, reading elements from left to right F order (column-major): Flattens column by column, reading elements from top to bottom Creating the DataFrame Let's start by creating a sample DataFrame with ID and Age columns ? ...

Read More

Write a program in Python to print dataframe rows as orderDict with a list of tuple values

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

In Pandas, you can convert DataFrame rows to OrderedDict objects with list of tuple values. This is useful when you need to maintain the order of columns and access row data in a structured dictionary format. Understanding the Problem When working with DataFrames, sometimes you need each row as an OrderedDict where each column-value pair is represented as a tuple. The expected output format is ? OrderedDict([('Index', 0), ('Name', 'Raj'), ('Age', 13), ('City', 'Chennai'), ('Mark', 80)]) OrderedDict([('Index', 1), ('Name', 'Ravi'), ('Age', 12), ('City', 'Delhi'), ('Mark', 90)]) OrderedDict([('Index', 2), ('Name', 'Ram'), ('Age', 13), ('City', 'Chennai'), ('Mark', 95)]) ...

Read More

Write a program in Python to caluculate the adjusted and non-adjusted EWM in a given dataframe

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

The Exponentially Weighted Moving Average (EWM) is a statistical technique that gives more weight to recent observations. Pandas provides two modes: adjusted (default) and non-adjusted, which handle the calculation differently during the initial periods. Understanding EWM Parameters The key difference between adjusted and non-adjusted EWM lies in how they handle the bias correction ? Adjusted EWM (default): Applies bias correction to account for the initialization period Non-adjusted EWM: Uses raw exponential weighting without bias correction com parameter: Center of mass, controls the decay rate (higher values = slower decay) Creating Sample Data First, ...

Read More

Write a Python code to fill all the missing values in a given dataframe

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

When working with datasets, missing values (NaN) are common. Pandas provides the interpolate() method to fill missing values using various interpolation techniques like linear, polynomial, or time-based methods. Syntax df.interpolate(method='linear', limit_direction='forward', limit=None) Parameters method − Interpolation technique ('linear', 'polynomial', 'spline', etc.) limit_direction − Direction to fill ('forward', 'backward', 'both') limit − Maximum number of consecutive NaNs to fill Example Let's create a DataFrame with missing values and apply linear interpolation ? import pandas as pd df = pd.DataFrame({"Id": [1, 2, 3, None, 5], ...

Read More
Showing 4301–4310 of 21,090 articles
« Prev 1 429 430 431 432 433 2109 Next »
Advertisements