#sort dataframe by col
sort.df <- with(df, df[order(sortbythiscolumn) , ])
#can also sort by more than one variable: sort by col1 and then by col2
sort2.df <- with(df, df[order(col1, col2) , ])
#sort in reverse order
sort2.df <- with(df, df[order(col1, -col2) , ])
Вы можете расширить AutoThrottle
промежуточное программное обеспечение, отвечающее за управление задержками, с помощью собственной политики:
# extensions.py
from scrapy.extensions.throttle import AutoThrottle
class ZombieThrottle(AutoThrottle):
"""start throttling when web page dies"""
def _adjust_delay(self, slot, latency, response):
"""Define delay adjustment policy"""
if response.status == 500:
slot.delay = 60 # 1 minute
И включить его вместо используемого по умолчанию в settings.py
:
# settings.py
EXTENSIONS = {
'scrapy.extensions.throttle.AutoThrottle': None,
'myspider.extensions.ZombieThrottle': 0,
}