I am stumped, I have tried half dozen unique ways to convert the columns of my dataframe from float64 to int64. The code below works for a DataFrame created here. but it fails on a dataframe created by my applications:
# result = pd.DataFrame([[1.0,2,3.0], [4,'',7], [None, None, None]])
result.info()
for col in result: result[col] = x = pd.to_numeric(result[col], errors='coerce', downcast='integer')
when result is constructed as shown here, the conversion works. When I try it a frame from my application the float64 columns remain float64. (I have tried, apply, as type, map solutions, and they all fail to change column type?! Here is the .info() from the frame I am trying to change:
<class 'pandas.core.frame.DataFrame'>
Index: 34 entries, AmzMisc to Travel
Data columns (total 26 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Totals 33 non-null float64
1 Monthly 33 non-null float64
2 2020-02 33 non-null float64
3 2020-03 33 non-null float64
4 2020-04 33 non-null float64
5 2020-05 33 non-null float64
6 2020-06 33 non-null float64
7 2020-07 33 non-null float64
8 2020-08 33 non-null float64
9 2020-09 33 non-null float64
10 2020-10 33 non-null float64
11 2020-11 33 non-null float64
12 2020-12 33 non-null float64
13 2021-01 33 non-null float64
14 2021-02 33 non-null float64
15 2021-03 33 non-null float64
16 2021-04 33 non-null float64
17 2021-05 33 non-null float64
18 2021-06 33 non-null float64
19 2021-07 33 non-null float64
20 2021-08 33 non-null float64
21 2021-09 33 non-null float64
22 2021-10 33 non-null float64
23 2021-11 33 non-null float64
24 2021-12 33 non-null float64
25 2022-01 33 non-null float64
dtypes: float64(26)
memory usage: 7.2+ KB
I must be missing something obvious here, since no one else complains of this kind of failure, but I am at a loss.