Replacing "." in columns - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Replacing "." in columns (/thread-27053.html) |
Replacing "." in columns - donnertrud - May-24-2020 Hi guys, I got a data set with missing values, however, those cells contain a "." instead of being empty. Here is an example : I want to resample the data to weeks with df = df.resample('1W').mean()But this gives me the error : DataError: No numeric types to aggregate I guess I have to replace the cells, but I don't know with what and moreover, I do know how replace the string "." in the column, but this will also replace the other already existing values. I appreciate any help! Edit : I tried the following : for i in range(len(df5["x"])): if df5["x"][i].isnumeric() is False: df5["x"][i] = df5["x][i].replace(".","") else: passBut this still replaces all "." RE: Replacing "." in columns - warnerarc - Jul-26-2021 This is due to the way GroupBy objects handle the different aggregation methods. In fact sum and mean are handled differently. GroupBy.mean dispatches to self._cython_agg_general which checks for numeric types and in case it doesn't find any it raises a DataError. |