
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
Found 10476 Articles for Python

176 Views
Suppose we have two values n and m. We have to find number of possible arrangements of humble matrices of order n x m. A matrix is said to be humble whenIt contains each element in range 1 to n x m exactly oncefor any two indices pairs (i1, j1) and (i2, j2), if (i1 + j1) < (i2 + j2), then Mat[i1, j1] < Mat[i2, j2] should hold.If the answer is too large then return result mod 10^9 + 7.So, if the input is like n = 2 m = 2, then the output will be 2, because there ... Read More

304 Views
Suppose, there is n number of cities and m roads connecting the cities. The citizens of the people need markets where they can buy their commodities. Now, there are no markets in the cities, and the roads between the cities are under construction.A two-way road can be built between two cities if (i) The city contains a market; (ii) The cities can be visited by the road where there is a market. The cost of building a road is x, and building a market is y and they are given. We have to find out the minimal cost to provide ... Read More

183 Views
Suppose, we have a tree that has all of its nodes numbered as 1 to n. Each of the nodes contains an integer value. Now if we remove an edge from the tree, the difference in the sum of the node values of the two sub-trees has to be minimal. We have to find out and return the minimum difference between such sub-trees. The tree is given to us as a collection of edges, and the values of the nodes are also provided.So, if the input is like n = 6, edge_list = [[1, 2], [1, 3], [2, 4], [3, ... Read More

263 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

112 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

143 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

175 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

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

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

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