Found 26504 Articles for Server Side Programming

Minimum no. of iterations to pass information to all nodes in the tree in C++

Sunidhi Bansal
Updated on 21-Oct-2021 13:41:59

808 Views

We are given a tree data structure with ‘n’ number of nodes. The given tree will have a root node and respective children which can be any number and further child can have any number of children. The task is to find the minimum number of iterations required by a root node of a tree to pass the information to all nodes in a tree. At a time, a node can pass information to one of its children and further one of its children can pass information to one of its children and meanwhile root node can pass information to ... Read More

Minimum 1s to lend power to make whole array powerful using C++

Sunidhi Bansal
Updated on 21-Oct-2021 12:20:54

110 Views

We are given a binary array which can store digits 1’s and 0’s of any given size and an integer variable let’s say, base. The task is to calculate the minimum 1’s that can lend power to other elements of a binary array such that the entire array becomes powerful. An element can lend power to its adjacent element or any other elements within the distance less than base.Let us see various input output scenarios for this -In − int arr[] = {1, 1, 0, 1, 1, 0, 1}, int base = 7Out −Minimum 1s to lend power to make ... Read More

Python Pandas BusinessHour offset object - Move to the next business day

AmitDiwan
Updated on 21-Oct-2021 08:59:04

302 Views

Move to the next business day using the BusinessHour.next_bday property in Pandas. At first, import the required libraries −import datetime import pandas as pdCreate the BusinessHour Offset. BusinessHour is the DateOffset subclass −bhOffset = pd.tseries.offsets.BusinessHour(offset = datetime.timedelta(days = 3, hours = 3)) Display the BusinessHour Offset −print("BusinessHour Offset...", bhOffset)Set the timestamp object in Pandas −timestamp = pd.Timestamp('2021-9-30 06:50:20') Display the next business day −print("The next business day...", timestamp + bhOffset.next_bday)ExampleFollowing is the code −import datetime import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-9-30 06:50:20') # Display the Timestamp print("Timestamp...", timestamp) # ... Read More

Python Pandas - Display the end time of the custom business hour in 24h format from the BusinessHour offset object

AmitDiwan
Updated on 21-Oct-2021 08:57:22

107 Views

To display the end time of the custom business hour in 24h format from the BusinessHour offset object, use the BusinessHour.end property.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-9-30 06:50:20') Create the BusinessHour Offset. Here, "start" is the start time of your custom business hour in 24h format. The "end" is the end time of your custom business hour in 24h format −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00", n = 8)Display the Updated Timestamp −print("Updated Timestamp...", timestamp + bhOffset) Display the end time of the custom business hour −print("The end ... Read More

Python Pandas - Display the start time of the custom business hour in 24h format from the BusinessHour offset object

AmitDiwan
Updated on 21-Oct-2021 08:51:57

115 Views

To display the start time of the custom business hour in 24h format from the BusinessHour offset object, use the BusinessHour.start property.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-9-30 06:50:20') Create the BusinessHour Offset. Here, "start" is the start time of your custom business hour in 24h format. The "end" is the end time of your custom business hour in 24h format −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00", n = 8)Display the Updated Timestamp − Display the start time of the custom business hour −print("The start time of the custom ... Read More

Python Pandas - Return the count of increments applied on the BusinessHour offset

AmitDiwan
Updated on 21-Oct-2021 08:39:39

76 Views

 To return the count of increments applied on the BusinessHour offset, use the BusinessHour.n property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-1-1 01:55:30')Create the BusinessHour Offset. Here, "start" is the start time of your custom business hour in 24h format. The "end" is the end time of your custom business hour in 24h format −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00", n = 8)Display the Updated Timestamp −print("Updated Timestamp...", timestamp + bhOffset)Return the count of increments on the given BusinessHour object −print("The count of increments on the BusinessHour object..", ... Read More

Python Pandas - Return the rule code applied on the given BusinessHour object

AmitDiwan
Updated on 21-Oct-2021 08:36:52

104 Views

To return the rule code applied on the given BusinessHour object, use the BusinessHour.rule_code property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-1-1 01:55:30') Create the BusinessHour Offset. BusinessHour is the DateOffset subclass −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00")Display the Updated Timestamp −print("Updated Timestamp...", timestamp + bhOffset) Return the rule code of the frequency applied on the given BusinessHour Offset −print("The rule code of the BusinessHour object..", bhOffset.rule_code)ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-1-1 01:55:30') # ... Read More

Python Pandas - Check whether the BusinessHour Offset has been normalized or not

AmitDiwan
Updated on 21-Oct-2021 08:34:59

112 Views

To check whether the BusinessHour Offset has been normalized or not, use the BusinessHour.normalize property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-1-1 01:55:30') Create the BusinessHour Offset. We have normalized the BusinessHour using the "normalize" parameter −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00", normalize=True)Display the Updated Timestamp −print("Updated Timestamp...", timestamp + bhOffset) Check whether the BusinessHour Offset is normalized or not −print("The BusinessHour Offset is normalized ?", bhOffset.normalize)ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-1-1 01:55:30') # ... Read More

Python Pandas - Return the name of the frequency applied on the given BusinessHour offset object

AmitDiwan
Updated on 21-Oct-2021 08:33:39

91 Views

To return the name of the frequency applied on the given BusinessHour offset object, use the BusinessHour.name property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-1-1 01:55:30') Create the BusinessHour Offset. BusinessHour is the DateOffset subclass −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00")Display the Updated Timestamp −print("Updated Timestamp...", timestamp + bhOffset) Return the name of the frequency applied on the given BusinessHour object −print("The name of the frequency on the BusinessHour object..", bhOffset.name)ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp = ... Read More

Python Pandas - Display the keyword arguments applied on the given BusinessHour object

AmitDiwan
Updated on 21-Oct-2021 08:32:08

98 Views

To display the keyword arguments applied on the given BusinessHour object, use the BusinessHour.kwds property in Pandas.At first, import the required libraries −import pandas as pdCreate the BusinessHour Offset. Here, "start" is the start time of your custom business hour in 24h format. The "end" is the end time of your custom business hour in 24h format −bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00") Set the timestamp object in Pandas −timestamp = pd.Timestamp('2021-1-1 01:55:30')Display the Updated Timestamp −print("Updated Timestamp...", timestamp + bhOffset) Display the keyword arguments −print("Keyword arguments on the given BusinessHour Offset...", bhOffset.kwds)ExampleFollowing is the code −import pandas as pd ... Read More

Advertisements