The invention provides a composition comprising at least one dopant, and a polymer containing at least one unit selected from the structure I shown in the specification, wherein M is selected from Fe, Co, or Ni; R1, R2, R3 , R4 and R5 are independently selected from hydrogen, deuterium, halogen, substituted or unsubstituted (C1-C16) alkyl, substituted or unsubstituted (C6-C16) aryl, substituted or unsubstituted (C3-C16) cycloalkyl, substituted or unsubstituted 5- to 7-membered heterocycloalkyl group, substituted or unsubstituted (C6-C16) aryl condensed with one or more cycloalkyls; 5- to 7- membered heterocycloalkyl group condensed with one or more substituted or unsubstituted aromatic rings or (C3-C16) cycloalkyl condensed with one or more substituted or unsubstituted aromatic rings, substituted or unsubstituted (C1-C16) silyl, cyano, nitro or hydroxyl; n is greater than or equal to 1; x is 0-4; y is 0-5; the dopant is a P-type dopant. The polymers containing and free of dopants can be used to prepare films and electronic devices, such as an organic light emitting diode (OLED).