The problem is that the context you pass to rdflib not only contains the context (@context) but also @id. The method, however, ignores everything but the context - which is correct btw. The reason why this works in the JSON-LD playground is that you add @id property to the body of the document, not the context. It becomes clear when the document you pass to the playground is printed like this: