For nearly two decades, we’ve been asking what it takes to get a New York City judge removed from the bench for misbehavior. We finally have the answer: Telling the members of the State Commission on Judicial Conduct to shove it.

That refusal to cooperate, on top of egregious courtroom behavior, is what led the commission to finally boot Queens Civil Court Judge Terrence O’Connor this week — after an investigation that began nearly two years ago.

Yet it’s a hollow victory: O’Connor’s 10-year term ends in December and he plans to appeal, so he may run out the clock.

This, when O’Connor’s expulsion appears richly justified by his repeated mistreatment of lawyers and other courtroom antics. (He’d already been censured in 2013 for other misbehavior.)

Plus, his blatant intransigence while being investigated (which itself constitutes misconduct) is cause alone for ouster.

As we’ve long noted, misbehavior by judges outside the five boroughs has long seemed to result in harsher discipline than within the city.

Case in point: The commission twice censured Manhattan Supreme Court Justice Diane Lebedeff for behavior it found “shocking” and “unacceptable” but let her remain on the bench until her term expired.

Removing a city judge isn’t unprecedented, but it’s extremely rare, which is what makes O’Connor’s case so notable.

And, yes, proving judicial misbehavior can be as difficult as convicting a politician for corruption. But that’s why the commission favors making all judicial-misconduct investigations fully public, including all questioning of witnesses and judges.

That’s now the practice in 34 states. But all efforts to make it the law in New York have failed to reach first base in Albany.

Is the Legislature so opposed to ethics reform that it won’t even do it for judges?