
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

258 Views
To return index locations of values between particular time of day in DateTimeIndex, use the DateTimeIndex.indexer_between_time() method.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 5 and frequency as T i.e. minutes. The timezone is Australia/Adelaide −datetimeindex = pd.date_range('2021-10-30 02:30:50', periods=5, tz='Australia/Adelaide', freq='20T') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Display index locations of values between particular time of day. The "start_time" is set '02:30:50' and "end_time" '03:20:50 −print("Index locations of values between particular time of day...", datetimeindex.indexer_between_time('02:30:50', '03:20:50'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as T i.e. minutes # ... Read More

602 Views
To return index locations of values at particular time of day in DateTimeIndex, use the DateTimeIndex.indexer_at_time() method.At first, import the required libraries −import pandas as pdCreate DatetimeIndex with period 5 and frequency as T i.e. minutes −datetimeindex = pd.date_range('2021-10-30 02:30:50', periods=5, tz='Australia/Adelaide', freq='20T') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Display index locations of values at particular time of day i.e. 03:10:50 here −print("Index locations of values at particular time of day...", datetimeindex.indexer_at_time('2021-10-30 03:10:50'))ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as T i.e. minutes # The timezone is Australia/Adelaide datetimeindex = pd.date_range('2021-10-30 02:30:50', periods=5, tz='Australia/Adelaide', ... Read More

320 Views
Suppose we have a list of elements called nums, we have to check whether every sublist has at least 1 element in it that occurs exactly once in the sublist or not. We have to solve this problem in linear time.So, if the input is like nums = [5, 10, 20, 10, 0], then the output will be True, because every sublist in nums has at least one element which has occurred only once. [[5], [10], [20], [10], [0], [5, 10], [10, 20], [20, 10], [10, 0], [5, 10, 20], [10, 20, 10], [20, 10, 0], [5, 10, 20, 10], ... Read More

208 Views
To detect the frequency of the given DatetimeIndex object, use the DateTimeIndex.inferred_freq property.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 5 and frequency as Y i.e. years. The timezone is Australia/Adelaide −datetimeindex = pd.date_range('2021-10-30 02:30:50', periods=5, tz='Australia/Adelaide', freq='3Y') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Display DateTimeIndex frequency −print("DateTimeIndex frequency...", datetimeindex.freq) ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 5 and frequency as Y i.e. years # The timezone is Australia/Adelaide datetimeindex = pd.date_range('2021-10-30 02:30:50', periods=5, tz='Australia/Adelaide', freq='3Y') # display DateTimeIndex print("DateTimeIndex...", datetimeindex) # display DateTimeIndex frequency print("DateTimeIndex frequency...", datetimeindex.freq) ... Read More

171 Views
To check whether the date in DateTimeIndex belongs to a leap year, use the DateTimeIndex.is_leap_year propertyAt first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 6 and frequency as Y i.e. years −datetimeindex = pd.date_range('2021-12-30 02:30:50', periods=6, tz='Australia/Adelaide', freq='3Y') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Check whether the date in DateTimeIndex is a leap year or not −print("Check whether the date in DateTimeIndex belongs to a leap year or not...", datetimeindex.is_leap_year)ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 6 and frequency as Y i.e. years # The timezone is Australia/Adelaide datetimeindex = pd.date_range('2021-12-30 02:30:50', ... Read More

1K+ Views
Suppose we have a binary matrix, where 0 is representing an empty cell, and 1 is a wall. If we start from top left corner (0, 0), we have to find the minimum number of cells it would take to get to bottom right corner (R-1, C-1) Here R is number of rows and C is number of columns. If we cannot find any answer, return -1.So, if the input is like00010001100001111000then the output will be 8 because, we can select path like −00010001100001111000To solve this, we will follow these steps −R := number of rowsC := number of columnsq ... Read More

149 Views
To check whether the date in DateTimeIndex is the last day of the year, use the DateTimeIndex.is_year_end property.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 6 and frequency as D i.e. days −datetimeindex = pd.date_range('2021-12-25 02:30:50', periods=6, tz='Australia/Adelaide', freq='2D') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Check whether the date in DateTimeIndex is the last day of the year −print("Check whether the date in DateTimeIndex is the last day of the year...", datetimeindex.is_year_end)ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 6 and frequency as D i.e. days # The timezone is Australia/Adelaide datetimeindex ... Read More

163 Views
To check whether the date in DateTimeIndex is the first day of the year, use the DateTimeIndex.is_year_start property.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 6 and frequency as D i.e. days −datetimeindex = pd.date_range('2021-12-30 02:30:50', periods=6, tz='Australia/Adelaide', freq='1D') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Check whether the date in DateTimeIndex is the first day of the year −print("Check whether the date in DateTimeIndex is the first day of the year...", datetimeindex.is_year_start)ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 6 and frequency as D i.e. days # The timezone is Australia/Adelaide datetimeindex ... Read More

257 Views
Suppose we have a list of numbers called nums, with unique positive numbers nums. We have to find the number of quadruples like (a, b, c, d) from nums such that a*b = c*d, a, b, c and d all are distinct elements of nums.So, if the input is like nums = [3, 6, 4, 8], then the output will be 8, because the quadruples are [[3, 8, 6, 4], [3, 8, 4, 6], [8, 3, 6, 4], [8, 3, 4, 6], [6, 4, 3, 8], [4, 6, 3, 8], [6, 4, 8, 3], [4, 6, 8, 3]].To solve this, ... Read More

265 Views
To check whether the date in DateTimeIndex is the last day of the quarter, use the DateTimeIndex.is_quarter_end property.At first, import the required libraries −import pandas as pdCreate a DatetimeIndex with period 6 and frequency as D i.e. days. The timezone is Australia/Adelaide −datetimeindex = pd.date_range('2021-6-15 02:30:50', periods=6, tz='Australia/Adelaide', freq='15D') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Check whether the date in DateTimeIndex is the last day of the quarter −print("Check whether the date in DateTimeIndex is the last day of the quarter...", datetimeindex.is_quarter_end)ExampleFollowing is the code −import pandas as pd # DatetimeIndex with period 6 and frequency as D i.e. days # The ... Read More