Server Side Programming Articles

Page 251 of 2109

Program to find stone removal rate in K hours in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 174 Views

Suppose we have a list of numbers called piles and a value k. The piles[i] represents the number of stones on pile i. On each hour, we select any pile and remove r number of stones from that pile. If we pick a pile with fewer than r stones, it still takes an hour to clear the pile. We have to find the minimum value of r, such that we can remove all the stones in less than or equal to k hours. So, if the input is like piles = [3, 6, 4] and k = 5, then ...

Read More

Python Pandas - Extract the day of week from the DateTimeIndex with specific time series frequency

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 338 Views

To extract the day of week from a DateTimeIndex with specific time series frequency, use the DateTimeIndex.dayofweek property. This property returns integers from 0-6 representing Monday through Sunday. Creating a DateTimeIndex with Frequency First, let's create a DateTimeIndex with a specific frequency using pd.date_range() ? import pandas as pd # Create DatetimeIndex with period 6 and frequency 3D (every 3 days) datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='3D') print("DateTimeIndex...") print(datetimeindex) DateTimeIndex... DatetimeIndex(['2021-10-20 02:30:50+11:00', '2021-10-23 02:30:50+11:00', '2021-10-26 ...

Read More

Python Pandas - Extract the ordinal day of year from the DateTimeIndex with specific time series frequency

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 384 Views

To extract the ordinal day of year from the DateTimeIndex with specific time series frequency, use the DateTimeIndex.dayofyear property. The ordinal day of year represents which day of the year it is (1-365 or 1-366 for leap years). Creating DateTimeIndex with Time Series Frequency First, let's create a DateTimeIndex with daily frequency and extract the day of year ? import pandas as pd # Create DatetimeIndex with period 6 and frequency as D (daily) # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='D') # Display DateTimeIndex print("DateTimeIndex...") print(datetimeindex) # Display ...

Read More

Program to find dropped correct sensor value from the faulty list in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 168 Views

Suppose we have two lists nums1 and nums2 representing sensor metrics. Each list contains unique values where no two elements are equal. One list holds accurate sensor metrics while the other contains faulty data. In the faulty list, one value (not the last) was dropped and a wrong value was placed at the end. We need to find the actual value that was dropped. For example, if nums1 = [5, 10, 15] and nums2 = [10, 15, 8], the output will be 5. The first list nums1 holds the actual values [5, 10, 15], while in the second array, ...

Read More

Python Pandas - Return numpy array of python datetime.time objects

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 398 Views

To return numpy array of python datetime.time objects, use the datetimeindex.time property in Pandas. This property extracts only the time component from datetime objects, discarding date and timezone information. Syntax DatetimeIndex.time This property returns a numpy array containing datetime.time objects. Creating a DatetimeIndex First, let's create a DatetimeIndex with timezone information ? import pandas as pd # Create DatetimeIndex with nanosecond frequency datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=3, tz='Australia/Sydney', freq='ns') print("DateTimeIndex...") print(datetimeindex) DateTimeIndex... DatetimeIndex(['2021-10-20 02:30:50+11:00', ...

Read More

Python Pandas - Extract the nanoseconds from the DateTimeIndex with specific time series frequency

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 617 Views

To extract the nanoseconds from the DateTimeIndex with specific time series frequency, use the DateTimeIndex.nanosecond property. This property returns an Int64Index containing the nanosecond values for each datetime in the index. Syntax DateTimeIndex.nanosecond Creating DateTimeIndex with Nanosecond Frequency First, let's create a DateTimeIndex with nanosecond frequency to demonstrate the nanosecond extraction ? import pandas as pd # Create DatetimeIndex with period 6 and frequency as ns (nanoseconds) # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='ns') # Display DateTimeIndex print("DateTimeIndex...", datetimeindex) DateTimeIndex... DatetimeIndex(['2021-10-20 ...

Read More

Program to count number of ways ball can drop to lowest level by avoiding blacklisted steps in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 294 Views

Suppose we have a value h and a list of numbers called blacklist. We are currently at height h, and are playing a game to move a small ball down to height 0. Now, in even rounds (starting from 0) we can move the ball 1, 2, or 4 stairs down. And in odd rounds, we can move the ball 1, 3, or 4 stairs down. Some levels are blacklisted. So if the ball reach there, it will die immediately. We have to find the number of ways the ball can move down at height 0. If the answer is ...

Read More

Python Pandas - Return numpy array of python datetime.date objects

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 652 Views

To return a numpy array of Python datetime.date objects from a Pandas DatetimeIndex, use the date property. This property extracts only the date part from timestamps, removing timezone information and returning standard Python date objects. Syntax datetimeindex.date Where datetimeindex is a Pandas DatetimeIndex object. Creating a DatetimeIndex First, let's create a DatetimeIndex with timezone information − import pandas as pd # Create DatetimeIndex with 3 periods and nanosecond frequency datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=3, tz='Australia/Sydney', freq='ns') print("DateTimeIndex...") print(datetimeindex) DateTimeIndex... DatetimeIndex(['2021-10-20 02:30:50+11:00', ...

Read More

Python Pandas - Extract the microseconds from the DateTimeIndex with specific time series frequency

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 245 Views

To extract the microseconds from a DateTimeIndex with specific time series frequency, use the DateTimeIndex.microsecond property. This property returns an Index containing the microsecond component of each datetime. Creating DateTimeIndex with Microsecond Frequency First, let's create a DateTimeIndex with microsecond frequency ? import pandas as pd # Create DatetimeIndex with period 6 and frequency as 'us' (microseconds) # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='us') print("DateTimeIndex...") print(datetimeindex) DateTimeIndex... DatetimeIndex(['2021-10-20 02:30:50+11:00', '2021-10-20 02:30:50.000001+11:00', ...

Read More

Python Pandas - Extract the seconds from the DateTimeIndex with specific time series frequency

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 576 Views

To extract the seconds from the DateTimeIndex with specific time series frequency, use the DateTimeIndex.second property. This property returns an Int64Index containing the second component of each datetime in the index. Syntax DateTimeIndex.second Creating a DateTimeIndex First, let's create a DateTimeIndex with a seconds frequency to demonstrate the extraction ? import pandas as pd # Create DatetimeIndex with period 6 and frequency as S (seconds) # The timezone is Australia/Sydney datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='S') # Display DateTimeIndex print("DateTimeIndex...", datetimeindex) DateTimeIndex... DatetimeIndex(['2021-10-20 02:30:50+11:00', '2021-10-20 02:30:51+11:00', ...

Read More
Showing 2501–2510 of 21,090 articles
« Prev 1 249 250 251 252 253 2109 Next »
Advertisements