Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1047 of 3363
130 Views
The process.connected property returns True if an IPC channel is connected and will return False after the process.disconnect() method is called. This happens only when the node process is spawned with an IPC channel (i.e., Child process and Cluster).Once the process.connected property is false, no messages can be sent over the IPC channel.Syntaxprocess.connectedExample 1Create two files "parent.js" and "child.js" as follows −parent.js// process.connected Property Demo Example // Importing the child_process modules const fork = require('child_process').fork; // Attaching the child process file const child_file = 'util.js'; // Spawning/calling child process const child = fork(child_file);child.jsconsole.log('In Child') // Check ... Read More
732 Views
The timers module contains functions that can execute code after a certain period of time. You do not need to import the timer module explicitly, as it is already globally available across the emulated browser JavaScript API.Timers module is mainly categorised into two categoriesScheduling Timers − This timer schedules the task to take place after a certain instant of time.setImmediate()setInterval()setTimeout()Cancelling Timers − This type of timers cancels the scheduled tasks which is set to take place. ClearImmediate()clearInterval()clearTimeout()Scheduling Timers1. setTimeout() MethodThe setTimeout() method schedules the code execution after a designated number of milliseconds. Only after the timeout has occurred, the code ... Read More
2K+ Views
To merge Pandas DataFrame, use the merge() function. The many-to-one relation is implemented on both the DataFrames by setting under the “validate” parameter of the merge() function i.e. −validate = “many-to-one” or validate = “m:1”The many-to-one relation checks if merge keys are unique in right dataset.At first, let us create our 1st DataFrame −dataFrame1 = pd.DataFrame( { "Car": ['BMW', 'Audi', 'Mustang', 'Bentley', 'Jaguar'], "Units": [100, 110, 80, 110, 90] } ) Now, let us create our 2nd DataFrame −dataFrame2 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', ... Read More
3K+ Views
Let’s say the following are the contents of our CSV file opened in Microsoft Excel −At first, load data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv")To select multiple column records, use the square brackets. Mention the columns in the brackets and fetch multiple columns from the entire dataset −dataFrame[['Reg_Price', 'Units']] ExampleFollowing is the code −import pandas as pd # Load data from a CSV file into a Pandas DataFrame: dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv") print("Reading the CSV file...", dataFrame) # displaying two columns res = dataFrame[['Reg_Price', 'Units']]; print("Displaying two columns : ", res)OutputThis will produce the ... Read More
1K+ Views
To select a subset of rows, use conditions and fetch data.Let’s say the following are the contents of our CSV file opened in Microsoft Excel −At first, load data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv")Let’s say we want the Car records with “Units” more than 100 i.e. subset of rows. For this, use −dataFrame[dataFrame["Units"] > 100] Now, let’s say we want the Car records with “Reg_Price” less than 100 i.e. subset of rows. For this, use −dataFrame[dataFrame["Reg_Price"] < 3000]ExampleFollowing is the code − import pandas as pd # Load data from a CSV file ... Read More
413 Views
Let’s say the following are the contents of our CSV file opened in Microsoft Excel −At first, load data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv")To select a subset, use the square brackets. Mention the column in the brackets and fetch single column from the entire dataset −dataFrame['Car'] ExampleFollowing is the code − import pandas as pd # Load data from a CSV file into a Pandas DataFrame dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv") print("Reading the CSV file...", dataFrame) # displaying only a single column res1 = dataFrame['Car']; # displaying only a subset print("Displaying only one column ... Read More
2K+ Views
To plot a DataFrame in a Line Graph, use the plot() method and set the kind parameter to line. Let us first import the required libraries −import pandas as pd import matplotlib.pyplot as mpFollowing is our data with Team Records −data = [["Australia", 2500, 2021], ["Bangladesh", 1000, 2021], ["England", 2000, 2021], ["India", 3000, 2021], ["Srilanka", 1500, 2021]]Set the data as Pandas DataFrame and add columns −dataFrame = pd.DataFrame(data, columns=["Team", "Rank_Points", "Year"]) Plot the Pandas DataFrame in a line graph. We have set the “kind” parameter as “line” for this −dataFrame.plot(x="Team", y=["Rank_Points", "Year" ], kind="line", figsize=(10, 9))ExampleFollowing is the code −import ... Read More
3K+ Views
Let’s say the following are the contents of our CSV file − Car Reg_Price 0 BMW 2000 1 Lexus 1500 2 Audi 1500 3 Jaguar 2000 4 Mustang 1500Import the required libraries −import pandas as pd import matplotlib.pyplot as mpOur CSV file is on the Desktop. Load data from a CSV file into a Pandas ... Read More
2K+ Views
To plot multiple columns, we will be plotting a Bar Graph. Use the plot() method and set the kind parameter to bar for Bar Graph. Let us first import the required libraries −import pandas as pd import matplotlib.pyplot as mpFollowing is our data with Team Records −data = [["Australia", 2500, 2021], ["Bangladesh", 1000, 2021], ["England", 2000, 2021], ["India", 3000, 2021], ["Srilanka", 1500, 2021]]Set the data as Pandas DataFrame and add columns −dataFrame = pd.DataFrame(data, columns=["Team", "Rank_Points", "Year"]) Plot multiple columns in a bar graph. We have set the “kind” parameter as “bar” for this −dataFrame.plot(x="Team", y=["Rank_Points", "Year" ], kind="bar", figsize=(10, ... Read More
2K+ Views
Bar Plot in Seaborn is used to show point estimates and confidence intervals as rectangular bars. The seaborn.barplot() is used for this. Plotting horizontal bar plots with dataset columns as x and y values. Use the estimator parameter to set median as the estimate of central tendency.Let’s say the following is our dataset in the form of a CSV file − Cricketers2.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as plt from numpy import medianLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers2.csv") Plotting horizontal bar plots with ... Read More