DOC: Adding example to head and tail method (#16416)
closes #18691 
- [X] closes #16416
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry
