Read XML File in PowerShell

Chirag Nagrekar
Updated on 11-Nov-2020 11:31:12

15K+ Views

Reading the XML file in PowerShell is easy. We have the below XML file for our example, Example                   Forest             Brown                         Street             Multi                         Forest             Yellow     Suppose this file is saved as Animals.xml to our current path and to read this XML file we ... Read More

Pass Arguments in Invoke-Command in PowerShell

Chirag Nagrekar
Updated on 11-Nov-2020 11:25:40

15K+ Views

To pass the argument in the Invoke-command, you need to use -ArgumentList parameter. For example, we need to get the notepad process information on the remote server.ExampleInvoke-Command -ComputerName Test1-Win2k12 - ScriptBlock{param($proc) Get-Process -Name $proc} - ArgumentList "Notepad"OutputHandles NPM(K) PM(K) WS(K) CPU(s)  Id SI ProcessName PSComputerName ------- ------ ----- ----- ------  -- -- ----------- --------------   67      8  1348  7488   0.08 104    notepad     Test1-Win2k12In the above example, we are passing "Notepad" name as the argument to the command and the same has been caught by the $proc variable inside Param().If you have the multiple, check the below command to pass the multiple parameters.ExampleInvoke-Command ... Read More

Select Multiple DataFrame Columns Using RegExp and DataTypes

Kiran P
Updated on 10-Nov-2020 10:04:29

814 Views

DataFrame maybe compared to a data set held in a spreadsheet or a database with rows and columns. DataFrame is a 2D Object.Ok, confused with 1D and 2D terminology ?The major difference between 1D (Series) and 2D (DataFrame) is the number of points of information you need to inorer to arrive at any single data point. If you take an example of a Series, and wanted to extract a value, you only need one point of reference i.e. row index.In comparsion to a table (DataFrame), one point of reference is not sufficient to get to a data point, you need ... Read More

Find and Filter Duplicate Rows in Pandas

Kiran P
Updated on 10-Nov-2020 09:38:28

7K+ Views

Sometimes during our data analysis, we need to look at the duplicate rows to understand more about our data rather than dropping them straight away.Luckily, in pandas we have few methods to play with the duplicates..duplciated()This method allows us to extract duplicate rows in a DataFrame. We will use a new dataset with duplicates. I have downloaded the Hr Dataset from link.import pandas as pd import numpy as np # Import HR Dataset with certain columns df = pd.read_csv("https://raw.githubusercontent.com/sasankac/TestDataSet/master/HRDataset.csv", usecols = ("Employee_Name""PerformanceScore", "Position", "CitizenDesc")) #Sort the values on employee name and make it permanent df.sort_values("Employee_Name"inplace = True) df.head(3)Employee_NamePositionCitizenDescPerformanceScore0AdinolfiProduction ... Read More

Find Airports in Correct Order in Python

Arnab Chakraborty
Updated on 10-Nov-2020 09:37:21

382 Views

Suppose we have a list of flights as [origin, destination] pairs. The list is shuffled; we have to find all the airports that were visited in the correct order. If there are more than one valid itinerary, return lexicographically smallest ones first.So, if the input is like flights = [["Mumbai", "Kolkata"], ["Delhi", "Mumbai"], ["Kolkata", "Delhi"] ], then the output will be ['Delhi', 'Mumbai', 'Kolkata', 'Delhi']To solve this, we will follow these stepsins := an empty mapouts := an empty mapadj_list := an empty mapDefine a function dfs() . This will take airportwhile outs[airport] is not null, donxt := size of ... Read More

Select a Subset of Data Using Lexicographical Slicing in Python Pandas

Kiran P
Updated on 10-Nov-2020 09:34:45

331 Views

IntroductionPandas have a dual selection capability to select the subset of data using the Index position or by using the Index labels. Inthis post, I will show you how to "Select a Subset Of Data Using lexicographical slicing".Google is full of datasets. Search for movies dataset in kaggle.com. This post uses the movies data set from kaggle.How to do it1. Import the movies dataset with only the columns required for this example.import pandas as pd import numpy as np movies = pd.read_csv("https://raw.githubusercontent.com/sasankac/TestDataSet/master/movies_data.csv", index_col="title", usecols=["title", "budget", "vote_average", "vote_count"]) movies.sample(n=5)titlebudgetvote_averagevote_countLittle Voice06.661Grown Ups 2800000005.81155The Best Years of Our Lives21000007.6143Tusk28000005.1366Operation Chromite05.8292. I always recommend ... Read More

Check If K Palindromes Can Be Made from Given String Characters in Python

Arnab Chakraborty
Updated on 10-Nov-2020 09:34:02

206 Views

Suppose we have a string s and another number k, we have to check whether we can create k palindromes using all characters in s or not.So, if the input is like s = "amledavmel" k = 2, then the output will be True, as we can make "level" and "madam".To solve this, we will follow these stepsd := a map where store each unique characters and their frequencycnt := 0for each key in d, doif d[key] is odd, thencnt := cnt + 1if cnt > k, thenreturn Falsereturn TrueLet us see the following implementation to get better understandingExamplefrom collections ... Read More

Create Charts in Excel Using Python with Openpyxl

Kiran P
Updated on 10-Nov-2020 09:32:41

2K+ Views

In this post, I will show you how to create charts in excel using Python - Openpyxl module. We will create an excel spreadsheet from scratch with Tennis players grandslam titles as the data for creating bar charts using the openpyxl module.Introduction..Microsoft office has started providing a new extension to Microsoft Excel sheets, which is .xlsx, from Office 2007 to support storing more rows and columns.This change had moved Excel sheets to a XML based file format with ZIP compression. The world is ruled by Microsoft spreadsheets, people have been using spreadsheets for various purposes and one of the use ... Read More

Find Minimum Number of Fibonacci Numbers to Add Up to N in Python

Arnab Chakraborty
Updated on 10-Nov-2020 09:28:33

364 Views

Suppose we have a number n; we have to find the minimum number of Fibonacci numbers required to add up to n.So, if the input is like n = 20, then the output will be 3, as We can use the Fibonacci numbers [2, 5, 13] to sum to 20.To solve this, we will follow these stepsres := 0fibo := a list with values [1, 1]while last element of fibo n, dodelete last element from fibon := n - last element of fibores := res + 1return resLet us see the following implementation to get better understandingExampleclass Solution:   ... Read More

Find Trailing Zeros in Factorial of n in C++

Arnab Chakraborty
Updated on 10-Nov-2020 09:25:30

213 Views

Suppose we have a number n, we have to find the number of trailing zeros of n!.So, if the input is like n = 20, then the output will be 4, as 20! = 2432902008176640000To solve this, we will follow these stepsset count := 0for i := 5, (n/i) > 1, update i := i * 5, docount := count + (n /i)return countLet us see the following implementation to get better understandingExample Live Demo#include #include #define MAX 20 using namespace std; int countTrailingZeros(int n) {    int count = 0;    for (int i = 5; n / i >= 1; i *= 5)       count += n / i;    return count; } main() {    int n = 20;    cout

Advertisements