Python Forum
Replacing "." in columns
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replacing "." in columns
#1
Hi guys,

I got a data set with missing values, however, those cells contain a "." instead of being empty. Here is an example :

[Image: YPsYKvz]

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:
        pass
But this still replaces all "."
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Replacing values for specific columns in Panda data structure Padowan 1 14,635 Nov-27-2017, 08:21 PM
Last Post: Padowan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020