Author: Arpit Mandliya
- 25 April
Convert Object to Float in Pandas
1. Introduction Pandas is python library for data analysis and manipulation. One of the common tasks is to convert data type of column from object to float. We can achieve this using astype() or to_numeric() methods. Method 1: Using astype() [crayon-67689eee2deef068546605/] Method 2: Using to_numeric() [crayon-67689eee2def6748581468/] Let’s see each method in detail with examples. 2. […]
- 25 April
PowerShell Check if List Contains String
Using -Contains Operator Use the -Contains operator to check if the list contains the specified string in PowerShell. [crayon-67689eee2ebd9184686543/] [crayon-67689eee2ebdf117140592/] In the above example, we used an array operator represented with @() to create a list, which we stored in the $list variable. Next, we initialized the $searchString variable with a string value we wanted […]
- 24 April
PowerShell Split and Get Last Value
Using Split() Method Use the Split() method with the indexing operator to split the specified string and get the last value in PowerShell. [crayon-67689eee2effa076992309/] [crayon-67689eee2efff075392905/] First, we defined a $string variable and initialized it with a string value, as shown in the above code fence. Next, we used the Split() method, passed whitespace as a […]
- 23 April
Convert XLSX to CSV in PowerShell
The xlsx file can be easily converted into csv using the following methods: Before converting a file, please ensure that your PowerShell is opened in the administrative mode, and the execution policy should not be set to Restricted. [crayon-67689eee2fb23460708242/] [crayon-67689eee2fb29740646669/] In the above code, we used the Get-ExecutionPolicy command to check if the execution policy […]
- 23 April
Convert CSV to XLSX in PowerShell
The csv file can be easily converted into xlsx using the following methods: Before converting files, please verify that your PowerShell is opened in administrative mode and that the execution policy is not set to Restricted. [crayon-67689eee2fcc1960672784/] [crayon-67689eee2fcc5581315657/] The above output demonstrates that the execution policy is set to Restricted. So, if the current execution […]
- 22 April
Run String as Command in PowerShell
Using Invoke-Expression Cmdlet Use the Invoke-Expression cmdlet to run a string as a command in PowerShell. Invoke-Expression cmdlet evaluates string as command and return the result of string expression. Here is simple exampple: [crayon-67689eee2fe0d302575890/] This will open new notepad window. Here is more complicated example. [crayon-67689eee2fe12510835686/] [crayon-67689eee2fe14890253987/] The Invoke-Expression evaluates a string as a PowerShell […]
- 22 April
Run Curl Command in PowerShell
In PowerShell 3.0 and higher, we have Invoke-WebRequest and Invoke-RestMethod cmdlets; curl is an alias of the Invoke-WebRequest in PowerShell. Most learners make it confused with the Invoke-RestMethod cmdlet. In PowerShell 7 and higher, the Invoke-RestMethod cmdlet is the default cmdlet for sending RESTful web service requests. It is another built-in cmdlet in PowerShell mainly […]
- 22 April
PowerShell Check if String Starts with
Using StartsWith() Method Use the StartsWith() to check if string starts with another string in PowerShell. [crayon-67689eee3017f590475999/] [crayon-67689eee30184654602789/] In the above code, a string variable named $text is initialized with the value of Hello, world! and another string variable called $prefix is created with the value of Hello. After that, using the StartsWith() method, the […]
- 22 April
PowerShell Check if Module is Installed
Using Get-Module Cmdlet Use Get-Module with -Name parameter to check if a module is installed in PowerShell. [crayon-67689eee30691187467571/] [crayon-67689eee30695026800587/] The Get-Module retrieves information about loaded modules and available modules that can be imported. The -ListAvailable parameter filters the results only to show available modules that can be imported but are not currently loaded. This parameter […]