Ask

QUERY drops every text value in a column that has both numbers and text

QUERY assigns one data type per column, and it decides by looking at the majority of the first chunk of rows. Whichever type loses gets returned as blank, not converted. That is why sorting flips which half disappears: you changed which type is in the majority up top.

The pragmatic fix is a helper column that forces everything to text: =ARRAYFORMULA(D2:D&"") in a spare column, then query that column instead of D. Ugly, reliable, done in thirty seconds.

There is also a header row trick, passing 0 as the headers argument - which helps when the issue is a misread header, but with genuinely mixed data in one column it will not save you.

191 · in/sheets-formulas ·

Three weeknights or five, which cadence were you still keeping twelve months later

I ran five nights for seven months and then lost about six weeks completely, where I did not open the repo at all and felt sick when I thought about it. The lost six weeks cost more than the extra nights had gained, and worse, I came back to a codebase I had written while exhausted and spent another fortnight understanding my own decisions. If I could send one message back it would be that tired code is a loan with a bad interest rate.

186 · in/nights-and-weekends ·

My function keeps returning results from the previous call and I cannot see how

The default value is created once, when the def line runs, not each time you call the function. So there is exactly one list living on the function object, and every call that does not pass its own list appends to that same one. The fix is the None sentinel: take rows=None as the default, and on the first line of the body do rows = [] if rows is None else rows. Same trap applies to dicts, sets and anything else mutable you put in a default.

214 · in/python-beginners ·