Use OTTR templates
Reasonable Ontology Templates (OTTR) is a language with supporting tools for representing and instantiating RDF graph and OWL ontology modelling patterns. It is designed to improve the efficiency and quality of building, using, and maintaining knowledge bases.
A Python package is available to define templates and pattern to allow to faithfully transform data to a specific data model.
See the pyOTTR GitHub repository and pyOTTR documentation.