Found 26504 Articles for Server Side Programming

Maximum Subarray Sum in a given Range in C++

Sunidhi Bansal
Updated on 22-Oct-2021 08:23:39

301 Views

We are given with an array of integer elements of any given size. The task is to find the maximum sum which will be calculated by forming the subarrays from the given array within the given range which can be started from any possible index value in an array.Let us see various input output scenarios for this -In − int arr[] = { 3, 2, -1, 6, 7, 2 }, int first = 0, int last = 5Out − Maximum Subarray Sum in a given Range is: 19Explanation − we are given with an array containing both positive and negative values and a ... Read More

Python Pandas CustomBusinessHour - Check if the given timestamp is on offset or not

AmitDiwan
Updated on 22-Oct-2021 08:11:30

264 Views

To check if the given timestamp is on offset or not, use the CustomBusinessHour.is_on_offset() in Pandas. Pass the timestamp as an argument to check.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-11-14 05:20:30') Create the CustomBusinessHour Offset. CustomBusinessHour is the DateOffset subclass −cbhOffset = pd.tseries.offsets.CustomBusinessHour(start="09:30", end = "18:30")Add the offset to the Timestamp and display the Updated Timestampprint("Updated Timestamp...", timestamp + cbhOffset) Check if the given timestamp is on offset or not −offset = cbhOffset.is_on_offset(pd.Timestamp('2021-11-20 05:20:30'))Display the result −print("Check if the given timestamp is on offset or not...", offset) ExampleFollowing is ... Read More

Python Pandas - Check if the given CustomBusinessHour is Anchored

AmitDiwan
Updated on 22-Oct-2021 08:09:20

113 Views

To check if the given CustomBusinessHour is Anchored, use the CustomBusinessHour.is_anchored() method in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-11-14 05:20:30') Create the CustomBusinessHour Offset. CustomBusinessHour is the DateOffset subclass −cbhOffset = pd.tseries.offsets.CustomBusinessHour(start="09:30", end = "18:30")Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbhOffset) Check whether the CustomBusinessHour is anchored −print("Check whether the CustomBusinessHour is anchored...", cbhOffset.is_anchored())ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-11-14 05:20:30') # Display the Timestamp print("Timestamp...", ... Read More

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

AmitDiwan
Updated on 22-Oct-2021 08:06:53

144 Views

To display the end time of the custom business hour in 24h format from the CustomBusinessHour offset object, use the CustomBusinessHour.end property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-11-14 05:20:30') Create the CustomBusinessHour 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 −cbhOffset = pd.tseries.offsets.CustomBusinessHour(start="09:30", end = "18:30", n = 5)Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbhOffset) Display the ... Read More

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

AmitDiwan
Updated on 22-Oct-2021 08:04:25

176 Views

To display the start time of the custom business hour in 24h format from the CustomBusinessHour offset object, use the CustomBusinessHour.start property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-11-14 05:20:30') Create the CustomBusinessHour 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 −cbhOffset = pd.tseries.offsets.CustomBusinessHour(start="09:30", end = "18:00", n = 8)Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbhOffset) Display the ... Read More

Python Pandas - Get the weekmask applied on the CustomBusinessHour offset

AmitDiwan
Updated on 22-Oct-2021 08:02:27

126 Views

To get the weekmask applied on the CustomBusinessHour offset, use the CustomBusinessHour.weekmask property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-11-14 05:20:30') Create the CustomBusinessHour Offset. CustomBusinessHour is the DateOffset subclass. Weekmask of valid business days −cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 7, weekmask = 'Mon Tue Wed Fri')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbhOffset) Display the weekmask −print("The weekmask on the CustomBusinessHour object..", cbhOffset.weekmask)ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp = ... Read More

Minimize the sum of roots of a given polynomial in C++

Sunidhi Bansal
Updated on 22-Oct-2021 08:18:10

133 Views

We are given with an array of integer elements representing the coefficient values of a polynomial. The size of an array will be ‘n’ i.e. number of elements in an array. The degree of polynomial always starts with n-1 as there will be one constant value at the end of the polynomial series. The task is to replace the coefficient with other polynomials in such a manner that sum of roots will be minimized.Let us see various input output scenarios for this -In − int arr[] = { 2, -1, 4, 9, -1, 10, -5}Out − Minimize the sum of roots of ... Read More

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

AmitDiwan
Updated on 22-Oct-2021 08:00:14

149 Views

To return the count of increments applied on the CustomBusinessHour offset, use the CustomBusinessHour.n property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-11-14 05:20:30') Create the CustomBusinessHour Offset. CustomBusinessHour is the DateOffset subclass −cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 7, weekmask = 'Mon Tue Wed Fri')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbhOffset) Return the count of increments on the given CustomBusinessHour object −print("The count of increments on the CustomBusinessHour object..", cbhOffset.n)ExampleFollowing is the code −import pandas as pd # Set the ... Read More

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

AmitDiwan
Updated on 22-Oct-2021 07:56:38

109 Views

To return the rule code applied on the given CustomBusinessHour object, use the CustomBusinessHour.rule_code property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-11-14 05:20:30')Create the CustomBusinessHour Offset. CustomBusinessHour is the DateOffset subclass −cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 4, weekmask = 'Mon Tue Wed Fri Sat' ,normalize=True)Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbhOffset)Return the rule code of the frequency applied on the given CustomBusinessHour Offset −print("The rule code of the CustomBusinessHour object..", cbhOffset.rule_code)ExampleFollowing is the code −import pandas as pd # ... Read More

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

AmitDiwan
Updated on 22-Oct-2021 07:51:30

102 Views

To check whether the CustomBusinessHour Offset has been normalized or not, use the CustomBusinessHour.normalize property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-10-25 08:35:10') Create the CustomBusinessHour Offset. CustomBusinessHour is the DateOffset subclass. We have normalized the CustomBusinessDay using the "normalize" parameter −cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 3, weekmask = 'Mon Tue Wed Fri Sat' ,normalize=True)Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbhOffset) Check whether the CustomBusinessHour Offset is normalized or not −print("The CustomBusinessHour Offset is normalized ?", cbhOffset.normalize)ExampleFollowing is the code ... Read More

Advertisements