dataframe.slice_shift() function is equivalent to a shift without copying the data. The displaced data will not include missing periods, and the displaced axis will be smaller than the original. This function simply resets the specified number of periods along the specified axis in the specified direction.
Syntax: DataFrame.slice_shift (periods = 1, axis = 0)
periods: Number of periods to move, can be positive or negative
Return: strong> shifted: same type as caller
Example # 1: Use
slice_shift () to shift the index axis by 2 periods in the temporal data row
Let's use the
dataframe.slice_shift () function to shift the index axis by 2 periods in the positive direction
Notice the index marks, the first two marks are discarded, but the data is offset by two periods in the positive direction.
We can also displace about placing the index in a negative direction for several periods
As a result, we see that the first two column labels are removed, and the data point along the column axis is offset by 2 periods in the positive direction. p >
We can also offset the column axis in the negative direction by multiple periods
In the output, we can see that the last two column labels have been removed and the data point along the column axis was shifted 2 periods in the negative direction (i.e. left).
A Gentle Introduction to Numerical Simulations with Python 3.6. Computing, in the sense of doing mathematical calculations, is a skill that mankind has developed over thousands of years. Programmin...
A Practical, No-Nonsense Introduction to Python Development. You already know you want to learn Python, and a smarter way to learn Python 3 is to learn by doing. The Python Workshop focuses on buil...
This book is an indispensable guide focuses on Machine Learning and R Programming, in an instructive and conversational tone which helps them who want to make their career in Big Data Analytics/ Data ...
Introduction to Machine Learning with Python: A Guide for Data Scientists 1st Edition. Machine learning has become an integral part of many commercial applications and research projects, but this f...