To get the Application security groups of the Azure VM using PowerShell, we need to first get the Network Interface of the Azure VM.The below command will retrieve the NIC name of the Azure VM.PS C:\> $vm = Get-AzVM -Name TestVM $nic = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]Once we have the NIC name, we can use the Get-AzNetworkInterface command to retrieve the NIC information and the Security group.The below command will retrieve the application security group names using PowerShell.PS C:\> $nicsettings = Get-AzNetworkInterface -Name $nic $nicsettings.IpConfigurations.ApplicationSecurityGroups
To get all the subnets attached to the virtual network using PowerShell, we need to use the GetAzVirtualNetwork command.PS C:\> $vn = Get-AzVirtualNetwork -Name VirtualNetworkNameTo get the Subnets and its address prefix details, you need to filter out the Subnets and AddressPrefixPS C:\> $vn.Subnets | Select Name, AddressPrefix
To get all the files that are modified after certain days, we need to use the LastWriteTime property.The below command shows us the files which are modified within the last 30 days in the C:\temp folder.Get-ChildItem C:\Temp | where{$_.LastWriteTime -ge (GetDate).AddDays(-30)}You can also use the AddMonths() or AddYears() instead of AddDays() as per your requirement.To get all the files that are modified before 30 days, use the below command.Get-ChildItem C:\Temp | where{$_.LastWriteTime -le (GetDate).AddDays(-30)}To get the file modified after a specific date, you need to compare the LastWriteTime with the Date. For example, we need all the files that are ... Read More
Power or Electric PowerThe rate at which work is done in an electric circuit is called as electric power. In other word, the work done per unit time is termed as electric power. It is denoted p or P.Formula and Unit of PowerWhen voltage is applied across a resistor, it causes current to flow through it. Therefore, work is being done in moving the electrons through the resistor in a unit time is called the electric power.Referring the above figure, $$\mathrm{V=\frac{work}{Q}}$$$$\mathrm{\Rightarrow work(W)=VQ=VIt}$$As, the power is defined as work done per unit time i.e.$$\mathrm{Power(P)=\frac{work\:done\:in\:electric\:circuit(W)}{Time(t)}=\frac{VIt}{t}}$$$$\mathrm{(∵V=IR\:or\:I=\frac{V}{R})}$$$$\mathrm{∴P=VI=I^2R=\frac{V^2}{R}}$$The above three formulae are equally valid for ... Read More
Suppose, we are playing a game where we are trapped in a maze. We have to find our way out of the maze. The maze can be presented as an x m matrix, where n is the number of rows and m is the number of columns. Each cell/element of the matrix contains any of the symbols 'O', 'D', 'S', or '-'. 'O' means that the path is blocked, 'D' is the way out from the maze, 'S' is our starting position, and '-' means we can move through the path. We can move freely through any of the '-' ... Read More
To combine two series into a DataFrame in Pandas, we can take two series and concatenate them using concat() method.StepsCreate series 1 with two elements, where index is ['a', 'b'] and name is Series 1.Print Series 1.Make Series 2 with two elements, where index is ['a', 'b'] and name is Series 2.Print Series 2.Concatenate Pandas objects along a particular axis with optional set logic along the other axes.Print the resultant DataFrame.Example Live Demoimport pandas as pd s1 = pd.Series([4, 16], index=['a', 'b'], name='Series 1') print "Input series 1 is: ", s1 s2 = pd.Series([3, 9], index=['a', 'b'], name='Series 2') print "Input series 2 is: ... Read More
To sort multiple columns of a Pandas DataFrame, we can use the sort_values() method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize a variable col to sort the column.Print the sorted DataFrame.Example Live Demoimport pandas as pd df = pd.DataFrame( { "x": [5, 2, 7, 0], "y": [4, 7, 5, 1], "z": [9, 3, 5, 1] } ) print "Input DataFrame is:", df col = ["x", "y"] df = df.sort_values(col, ascending=[False, True]) print "After sorting column ", col, "DataFrame is:", dfOutputInput DataFrame is: x y z 0 5 4 9 1 2 7 3 2 7 5 5 3 0 1 1 After sorting column ['x', 'y'] DataFrame is: x y z 2 7 5 5 0 5 4 9 1 2 7 3 3 0 1 1
To sort a column in a Pandas DataFrame, we can use the sort_values() method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print input DataFrame, df.Initialize a variable col to sort the column.Print the sorted DataFrame.Example Live Demoimport pandas as pd df = pd.DataFrame( { "x": [5, 2, 7, 0], "y": [4, 10, 5, 1], `"z": [9, 3, 5, 1] } ) print "Input DataFrame is:", df col = "x" df = df[col].sort_values(ascending=False) print "After sorting column ", col, "DataFrame is:", dfOutputInput DataFrame is: x y z 0 5 4 9 1 2 10 3 2 7 5 5 3 0 1 1 After sorting column x DataFrame is: 2 7 0 5 1 2 3 0 Name: x, dtype: int64
We can use apply() function on a column of a DataFrame with lambda expression.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print input DataFrame, df.Override column x with lambda x: x*2 expression using apply() method.Print the modified DataFrame.Example Live Demoimport pandas as pd df = pd.DataFrame( { "x": [5, 2, 1, 5], "y": [4, 10, 5, 10], "z": [1, 1, 5, 1] } ) print "Input DataFrame is:", df df['x'] = df['x'].apply(lambda x: x * 2) print "After applying multiplication of 2 DataFrame is:", dfOutputInput DataFrame is: x y z 0 5 4 1 1 2 10 1 2 1 5 5 3 5 10 1 After applying multiplication of 2 DataFrame is: x y z 0 10 4 1 1 4 10 1 2 2 5 5 3 10 10 1
To count the frequency of a value in a DataFrame column in Pandas, we can use df.groupby(column name).size() method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Print frequency of column, x.Print frequency of column, y.Print frequency of column, z.Example Live Demoimport pandas as pd df = pd.DataFrame( { "x": [5, 2, 1, 5], "y": [4, 10, 5, 10], "z": [1, 1, 5, 1] } ) print "Input DataFrame is:", df col = "x" count = df.groupby('x').size() print "Frequency of values in column ", col, ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP