Found 26504 Articles for Server Side Programming

Python - Create a Time Series Plot with multiple columns using Line Plot

AmitDiwan
Updated on 30-Sep-2021 12:29:34

3K+ Views

To create a Time Series Plot with multiple columns using Line Plot, use the lineplot(). At first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltCreate a DataFrame. We have multiple columns in our DataFrame −dataFrame = pd.DataFrame({'Date_of_Purchase': ['2018-07-25', '2018-10-25', '2019-01-25', '2019-05-25', '2019-08-25', '2020-09-25', '2021-03-25'], 'Units Sold': [98, 77, 51, 70, 70, 87, 76], 'Units Returned' : [60, 50, 40, 57, 62, 51, 60] })Plot time series plot for multiple columns −sb.lineplot(x="Date_of_Purchase", y="Units Sold", data=dataFrame) sb.lineplot(x="Date_of_Purchase", y="Units Returned", data=dataFrame)ExampleFollowing is the code −import seaborn as sb import pandas as pd import matplotlib.pyplot as ... Read More

Express.js – app.engine() Method

Mayank Agarwal
Updated on 30-Sep-2021 12:37:41

704 Views

The app.engine() method is used for registering the given template engine callback as "ext". The require() method needs the engine based on the function by default.Use the following methods for engines that do not provide the extensions (or want to map different extensions) or express out of the box.app.engine('html', require('ejs').renderFile)Syntaxapp.engine(ext, callback)Example 1Create a file with the name "appEngine.js" and copy the following code snippet. After creating the file, use the command "node appEngine.js" to run this code.// app.engine() Method Demo Example // Importing the express module const express = require('express'); // Initializing the express and port number var ... Read More

Python Pandas - Draw a set of Horizontal point plots with Seaborn

AmitDiwan
Updated on 30-Sep-2021 12:24:24

199 Views

Horizontal point plots are a plotting based on the values of x and y i.e. the columns of the dataset you consider. Point Plot in Seaborn is used to show point estimates and confidence intervals using scatter plot glyphs. The seaborn.pointplot() is used for this.Let’s say the following is our dataset in the form of a CSV file − Cricketers.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers.csv")Now, use the pointplot() and set the x and y values −sb.pointplot(x ... Read More

Express.js – app.enable() Method

Mayank Agarwal
Updated on 30-Sep-2021 12:16:52

565 Views

The app.enable() function sets the Boolean setting ‘name’ to ‘true’, where name defines one of the properties from the app settings table. Using the app.set('foo', true) for a Boolean property is same as calling the app.enable('foo') function.Syntaxapp.enable(name)Example 1Create a file with the name "appEnable.js" and copy the following code snippet. After creating the file, use the command "node appEnable.js" to run this code.// app.enable() Method Demo Example // Importing the express module const express = require('express'); // Initializing the express and port number var app = express(); // Initializing the router from express var router = express.Router(); ... Read More

Express.js – app.disable() Method

Mayank Agarwal
Updated on 30-Sep-2021 12:13:31

747 Views

The app.disable() method disables the setting name passed in the function. This method sets the setting name to False. We can perform the same function by using the app.set() method too, by passing its value as False.Syntaxapp.disable(name)Example 1Create a file with the name "appDisable.js" and copy the following code snippet. After creating the file, use the command "node appDisable.js" to run this code.// app.disable() Method Demo Example // Importing the express module const express = require('express'); // Initializing the express and port number var app = express(); // Initializing the router from express var router = express.Router(); ... Read More

How to apply the aggregation list on every group of pandas DataFrame?

AmitDiwan
Updated on 30-Sep-2021 12:13:18

147 Views

To apply the aggregation list, use the agg() method. At first, import the required library −import pandas as pdCreate a DataFrame with two columns −dataFrame = pd.DataFrame(    {       "Car": ['BMW', 'Lexus', 'Lexus', 'Mustang', 'Bentley', 'Mustang'], "Units": [100, 150, 110, 80, 110, 90] } )Specifying list as argument using agg() −dataFrame = dataFrame.groupby('Car').agg(list) ExampleFollowing is the complete code −import pandas as pd # Create DataFrame dataFrame = pd.DataFrame(    {       "Car": ['BMW', 'Lexus', 'Lexus', 'Mustang', 'Bentley', 'Mustang'], "Units": [100, 150, 110, 80, 110, 90] } ) ... Read More

Express.js – app.delete() Method

Mayank Agarwal
Updated on 30-Sep-2021 12:09:47

7K+ Views

The app.delete() method routes all the HTTP DELETE requests to the specified path with the specified callback functions.Syntaxapp.delete(path, callback, [callback])Parameterspath − This is the path for which the middleware function is invoked. A path can be a string, path pattern, a regular expression, or an array of all these.callback − These are the middleware functions or a series of middleware functions that act like a middleware except that these callbacks can invoke next (route).Example 1Create a file "appDelete.js" and copy the following code snippet. After creating the file, use the command "node appDelete.js" to run this code.// app.delete() Method Demo ... Read More

Python Pandas - Draw a set of vertical point plots grouped by a categorical variable with Seaborn

AmitDiwan
Updated on 30-Sep-2021 12:05:47

201 Views

Point Plot in Seaborn is used to show point estimates and confidence intervals using scatter plot glyphs. The seaborn.pointplot() is used for this. For vertical point plot grouped by a categorical variable, set the variable as a value for the pointplot().Let’s say the following is our dataset in the form of a CSV file − Cricketers.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers.csv") Vertical point plot grouped by a categorical variable −sb.pointplot(dataFrame['Role'], dataFrame['Age'])ExampleFollowing is the code −import seaborn ... Read More

Express.js – app.all() Method

Mayank Agarwal
Updated on 30-Sep-2021 12:01:14

3K+ Views

The app.all() method can be used for all types of routings of a HTTP request, i.e., for POST, GET, PUT, DELETE, etc., requests that are made to any specific route. It can map app types of requests with the only condition that the route should match.Syntaxapp.path(path, callback, [callback])Parameterspath − This is the path for which the middleware function is invoked. A path can be a string, path pattern, a regular expression or an array of all these.callback − These are the middleware functions or a series of middleware functions that act like a middleware except that these callbacks can invoke ... Read More

Python Pandas - Replace all NaN elements in a DataFrame with 0s

AmitDiwan
Updated on 30-Sep-2021 11:59:22

321 Views

To replace NaN values, use the fillna() method. Let’s say the following is our CSV file opened in Microsoft Excel with some NaN values −At first, import the required library −import pandas as pdLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv")Replace NaN values with 0s using the fillna() method −dataFrame.fillna(0)ExampleFollowing is the codeimport pandas as pd # Load data from a CSV file into a Pandas DataFrame dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv") print("DataFrame...", dataFrame) # replace NaN values with 0s res = dataFrame.fillna(0) print("DataFrame after replacing NaN values...", res)OutputThis will produce the following output −DataFrame... ... Read More

Advertisements