Python’s str.rsplit method splits a string from the right. Supplying a separator and a maximum split count controls where the result is divided. section 8.2
Split a dotted column name
s = 'abcd.efgh.ijkl'\ns.rsplit('.', 1)\n# ['abcd.efgh', 'ijkl']\n\nWith a maximum of 1, the final period separates the column’s category from its final name. Unpacking the result into first and rest produces a tuple suitable for pandas.MultiIndex.from_tuples. section 8.2
