To convert Period to desired frequency, use the period.asfreq() method. Let’s say we will set to desired Hourly frequency using the ‘H’ specifier.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Create two Period objectsperiod1 = pd.Period("2020-09-23 03:15:40") period2 = pd.Period(freq="D", year = 2021, month = 4, day = 16, hour = 2, minute = 35)Display the Period objectsprint("Period1...", period1) print("Period2...", period2)Convert Period to desired frequency. We have set frequency as H i.e. Hourly frequencyres1 = period1.asfreq('H') res2 = period2.asfreq('H')ExampleFollowing is the code import pandas as pd # The pandas.Period represents a ... Read More
To get the year from the Period object, use the period.year property. At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objectsperiod1 = pd.Period("2020-09-23") period2 = pd.Period(freq="D", year = 2021, month = 4, day = 16, hour = 2, minute = 35)Display the Period objectsprint("Period1...", period1) print("Period2...", period2)Get the year from two Period objectsres1 = period1.year res2 = period2.yearExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2020-09-23") period2 = pd.Period(freq="D", year = 2021, month ... Read More
To get the week of the year on the given Period, use the period.weekofyear property. At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objectsperiod1 = pd.Period("2020-09-23") period2 = pd.Period(freq="D", year = 2021, month = 4, day = 16, hour = 2, minute = 35)Display the Period objectsprint("Period1...", period1) print("Period2...", period2)Get the week of the year from two Period objectsres1 = period1.weekofyear res2 = period2.weekofyearExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2020-09-23") period2 ... Read More
To find the start time for the given Period object, use the period.start_time property. At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating two Period objectsperiod1 = pd.Period("2020-09-22") period2 = pd.Period(freq="D", year = 2021, month = 2, day = 14, hour = 2, minute = 35)Display the Period objectsprint("Period1...", period1) print("Period2...", period2)Get the start time from two Period objectsres1 = period1.start_time res2 = period2.start_timeExampleFollowing is the code import pandas as pd # The pandas.Period represents a period of time # creating two Period objects period1 = pd.Period("2020-09-22") period2 = pd.Period(freq="D", year ... Read More
Suppose we have a list of numbers called nums, where all elements are unique. We have to find the length of the longest sublist that contains consecutive elements.So, if the input is like nums = [3, 6, 7, 5, 4, 9], then the output will be 5, because the sublist is [3, 6, 7, 5, 4] this contains all consecutive elements from 3 to 7.To solve this, we will follow these steps −ret := 0for i in range 0 to size of nums - 1, dolhs := nums[i]rhs := nums[i]for j in range i to size of nums - 1, ... Read More
Units of Synchronizing Power Coefficient (𝑷𝐬𝐲𝐧)Generally, the synchronizing power coefficient is expressed in Watts per electrical radian, i.e., $$\mathrm{𝑃_{syn} =\frac{𝑉 𝐸_{𝑓}}{𝑋_{𝑠}}cos\:𝛿 \:\:Watts/electrical\:radian …(1)}$$$$\mathrm{∵ \:𝜋\:radians = 180\:degrees}$$$$\mathrm{\Rightarrow\:1\:radian =\frac{180}{𝜋}\:degrees}$$$$\mathrm{∵ \:𝑃_{syn}=\frac{𝑑𝑃}{𝑑𝛿}\:\:Watts/ \left(\frac{180}{𝜋}\:degrees \right)}$$$$\mathrm{\Rightarrow\:𝑃_{syn}=\left( \frac{𝑑𝑃}{𝑑𝛿}\right)\left(\frac{𝜋}{180}\right)\:\:Watt/electrical\:degree …(2)}$$If p is the total number of pole pairs in the machine, then$$\mathrm{𝜃_{electrical} = 𝑝 \cdot 𝜃_{mechanical}}$$Therefore, the synchronizing power coefficient per mechanical radian is given by, $$\mathrm{𝑃_{syn} = 𝑝 \cdot\left( \frac{𝑑𝑃}{𝑑𝛿}\right)\:\:Watts/mech. radian …(3)}$$And, the synchronizing power coefficient per mechanical degree is given by, $$\mathrm{𝑃_{syn} =\left( \frac{𝑑𝑃}{𝑑𝛿}\right)\left(\frac{𝑝\:𝜋}{180}\right)\:Watts/mech.degree …(4)}$$Significance of Synchronizing Power CoefficientThe synchronizing power coefficient ($𝑃_{syn}$) is the measure of the stiffness of the electromagnetic coupling between the stator ... Read More
Suppose we are given a positive integer number. We have to spell the number in words; like if a number "56" is given as input the output will be "Fifty-Six". The range of conversion is up to a billion.So, if the input is like input = 5678, then the output will be Five Thousand Six Hundred Seventy-Eight.To solve this, we will follow these steps −Define an array ‘numbers’ that contain pairs such as − {{"Billion", 1000000000}, {"Million", 1000000}, {"Thousand", 1000}, {"Hundred", 100}, {"Ninety", 90}, {"Eighty", 80}, {"Seventy", 70}, {"Sixty", 60}, {"Fifty", 50}, {"Forty", 40}, {"Thirty", 30}, {"Twenty", 20}, {"Nineteen", 19}, ... Read More
Suppose we are given a binary tree that has a root node 'root' and a linked list that has a head node 'head'. We have to find out if that linked list exists in that binary tree. If a set of nodes in the tree have links with each other in order as a linked list, and if that order is similar to that of the provided linked list, then we return 'True' or otherwise, we return 'False'.So, if the input is likeTreeLinked Listthen the output will be True.To solve this, we will follow these steps −arr := a new ... Read More
Suppose we are provided a binary tree. We have to find out if there exist binary search trees (BST) in the subtrees of it and find out the sum of the largest BST. To find out the sum, we add the values of each node in that BST. We return the sum value as output.So, if the input is likethen the output will be 12.The BST in the given binary tree is −sum of the nodes = 12.To solve this, we will follow these steps −c := 0m := nullvalue := 0Define a function recurse() . This will take nodeif ... Read More
Suppose we are given a binary tree. We have to find out the largest subtree from the tree that is a binary search tree (BST). We return the root node of the BST.So, if the input is likethen the output will be −To solve this, we will follow these steps −c := 0m := nullDefine a function recurse() . This will take nodeif node is not null, thenleft_val := recurse(left of node)right_val := recurse(right of node)count := negative infinityif (node.left is same as null or node.left.val
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP