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 965 of 3363
227 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
191 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
169 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
176 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
292 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
288 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
148 Views
To check whether the date in DateTimeIndex is the first day of the quarter, use the DateTimeIndex.is_quarter_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-10-1 02:30:50', periods=6, tz='Australia/Adelaide', freq='30D') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Check whether the date in DateTimeIndex is the first day of the quarter −print("Check whether the date in DateTimeIndex is the first day of the quarter...", datetimeindex.is_quarter_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
167 Views
To check whether the date in DateTimeIndex is the last day of the month, use the DateTimeIndex.is_month_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-9-15 06:40:35', periods=6, tz='Australia/Adelaide', freq='15D') Display DateTimeIndex −print("DateTimeIndex...", datetimeindex)Check whether the date in DateTimeIndex is the last day of the month −print("Check whether the date in DateTimeIndex is the last day of the month...", datetimeindex.is_month_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
147 Views
Suppose we have a list of numbers called nums. The length of this list is even. Now consider an operation where we select any number in nums and update it with a value in range [1 and maximum of nums]. We have to find the minimum number of such operations required such that, for every i, nums[i] + nums[n-1-i] equals to the same number.So, if the input is like nums = [8, 6, 2, 5, 9, 2], then the output will be 2, because if we change first 2 at nums[2] to 5, and 9 at nums[4] to 4, then ... Read More