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 953 of 3363
227 Views
To change the frequency of the given Period object from Seconds to Minutely frequency, use the period.asfreq() method and set the parameter ‘T’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period object. We have set the frequency as seconds i.e. 'S' using the 'freq' parameter period = pd.Period(freq="S", year = 2021, month = 9, day = 11, hour = 8, minute = 20, second = 45)Display the Period object with Seconds frequencyprint("Period...", period) Convert Period from Seconds to Minutely frequency. We have set the "T" to convert seconds to minutely ... Read More
757 Views
To change the frequency of the given Period object from Seconds to Hourly frequency, use the period.asfreq() method and set the parameter ‘H’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period object. We have set the frequency as seconds ie. 'S' using the 'freq' parameterperiod = pd.Period(freq="S", year = 2021, month = 4, day = 16, hour = 2, minute = 35, second = 15) Display the Period object with Seconds frequencyprint("Period...", period)Convert Period from Seconds to Hourly frequency. We have set the "H" to convert seconds to hourly frequency ... Read More
566 Views
To change the frequency of the given Period object from Seconds to Daily frequency, use the period.asfreq() method and set the parameter ‘D’.At first, import the required libraries −import pandas as pdThe pandas.Period represents a period of time. Creating a Period object. We have set the frequency as seconds ie. 'S' using the 'freq' parameterperiod = pd.Period(freq="S", year = 2021, month = 4, day = 16, hour = 2, minute = 35, second = 15)Display the Period object with Seconds frequencyprint("Period...", period) Convert Period from Seconds to Daily frequency. We have set the "D" to convert seconds to daily frequency ... Read More
617 Views
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
571 Views
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
238 Views
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
345 Views
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
230 Views
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
193 Views
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
412 Views
Suppose we are given a list containing several integer numbers. We have to find out the difference between each pair of values in the array and find out the k-th smallest difference number. The index starts at 0 and the value k is given to us as input.So, if the input is like numbers = {2, 6, 4, 8}, k = 2, then the output will be 2.The differences between the pairs are −(2, 6) = 4(2, 4) = 2(2, 8) = 6(6, 4) = 2(6, 8) = 2(4, 8) = 4If we sort the values, it becomes 2, 2, ... Read More