Last active
June 14, 2018 19:15
-
-
Save ljwolf/ba3f41df984d7064440e8a24e25ae9f1 to your computer and use it in GitHub Desktop.
Pandas Rolling String example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import string | |
df = pd.DataFrame([[*string.ascii_letters[0:26:2]], | |
*string.ascii_letters[1:26:2]]) | |
rolled = df.rolling(window=2, center=False, axis=1).apply(lambda x: ''.join(x)) | |
#expected: [['ac', 'ce', 'eg', 'gi', 'ik', 'km', 'mo', 'oq', 'qs', 'su', 'uw', 'wy'], | |
# 'bd', 'df', 'fh', 'hj', 'jl', 'ln', 'np', 'pr', 'rt', 'tv', 'vx', 'xz']] | |
print(rolled.values) | |
#is the original dataframe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not work...