pull request for the code - https://github.com/pandas-dev/pandas/pull/16589#pullrequestreview-41919702