NIHAO – IV: core creation and destruction in dark matter density profiles across cosmic time