One solution would be to inherit the pd.DataFrame class (aka creating a subclass of pd.DataFrame) as described in the official docs. then you can modify its constructor to change the style. The class should be like this:
class CustomDataFrame(pd.DataFrame):
@property
def _constructor(self):
# change style. you can move this into another function as well.
self.style \
.format(precision=3, thousands=".", decimal=",") \
.format_index(str.upper, axis=1) \
.hide(axis="index")
# return an instance of CustomDataFrame
return CustomDataFrame
Then, you can use this class the same as the pd.DataFrame. For example run this:
data = [['Mj', 27], ['Sarah', 5]]
df = CustomDataFrame(data, columns = ['Name', 'Age'])
df.head()