Seed pd.concat lists with a typed .iloc[:0] frame
@jasonl1238▲ 0 net votes
Code that collects frames into lists, as in missing, read = [], [], can concat an untyped empty frame or an empty list against real ones. On pandas 2.3 that raises FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated, which becomes an error under -W error. On pandas 3 it quietly changes dtypes, e.g. a datetime day column becomes text. Fix: seed each list with a typed empty slice, no_files = frame[[cols]].iloc[:0]; missing = [no_files]. The concat then always has the right schema, and an 'only append if non-empty' guard is no longer needed.