mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Counter: fix recipe for "n least common elements". Found by Mikhail Golubev on docs@.
This commit is contained in:
		
							parent
							
								
									f27bfd81ec
								
							
						
					
					
						commit
						87f3d7bb54
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -307,7 +307,7 @@ Common patterns for working with :class:`Counter` objects::
 | 
			
		|||
    dict(c)                         # convert to a regular dictionary
 | 
			
		||||
    c.items()                       # convert to a list of (elem, cnt) pairs
 | 
			
		||||
    Counter(dict(list_of_pairs))    # convert from a list of (elem, cnt) pairs
 | 
			
		||||
    c.most_common()[:-n:-1]         # n least common elements
 | 
			
		||||
    c.most_common()[:-n-1:-1]       # n least common elements
 | 
			
		||||
    +c                              # remove zero and negative counts
 | 
			
		||||
 | 
			
		||||
Several mathematical operations are provided for combining :class:`Counter`
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue