Tre metri sopra il cielo me titra shqip
Cristian Lazzari tre metri sopra il cielo me titra shqip
Every time I place my head upon your shoulder/I count the white
Donna me sfonin fb842f711db
15:42:26 22/01/14 Sun Author: suomik. Subject: Donna me sfonin. I am all ears Please, sing me Donna me sfonin.
-kvgrbghjtfrb.txt
031
Q:
How to obtain every 100th of time series data in Pandas?
I'm trying to extract every 100th element in a time series. For example, to obtain the 1st through the 100th, 200th through the 300th, 400th through the 500th, 600th through the 700th, 800th through the 900th, 1000th through the 1100th, 1200th through the 1300th, etc.
Ideally, the code I'm trying to write looks something like:
for index, row in df.iterrows():
if (index+1) % 100 == 0:
print(row[1])
I can't seem to get this to work, though, and keep getting errors like:
AttributeError: 'pandas.core.series.Series' object has no attribute 'iterrows'
What's the right way to do this?
A:
You can use groupby() and slicing:
In [10]: df = pd.DataFrame({'a': range(1, 5)})
In [11]: df.groupby(df.index//100).apply(lambda x: x.iloc[::100])
Out[11]:
a
0 1.0
1 2.0
2 3.0
3 4.0
For multiindex data, you can use applymap() instead of apply():
In [22]: df.index//100
Out[22]: MultiIndex(levels=[['0', '0.25', '0.5', '0.75', '1'], ['1', '1.25', '1. be359ba680
Related links:
Comments