pandas.DataFrame.replace — pandas 0.25.3 documentation | data replace
Replacevaluesgiveninto_replacewithvalue.ValuesoftheDataFramearereplacedwithothervaluesdynamically.Thisdiffersfromupdatingwith.locor.iloc,whichrequireyoutospecifyalocationtoupdatewithsomevalue.Parametersto_replacestr,regex,list,dict,Series,int,float,orNoneHowtofindthevaluesthatwillbereplaced.Seetheexamplessectionforexamplesofeachofthese.valuescalar,dict,list,str,regex,defaultNoneValuetoreplaceanyvaluesmatchingto_replacewith.ForaDataFrameadictofvaluescanbeusedtospecifywhichvaluetouseforeachcol...
Replace values given in to_replace with value.
Values of the DataFrame are replaced with other values dynamically.
This differs from updating with .loc or .iloc, which require you to specify a location to update with some value.
Parameters to_replacestr, regex, list, dict, Series, int, float, or NoneHow to find the values that will be replaced.
See the examples section for examples of each of these.
valuescalar, dict, list, str, regex, default NoneValue to replace any values matching to_replace with. For a DataFrame a dict of values can be used to specify which value to use for each column (columns not in the dict will not be filled). Regular expressions, strings and lists or dicts of such objects are also allowed.
inplacebool, default FalseIf True, performs operation inplace and returns None.
limitint, default NoneMaximum size gap to forward or backward fill.
regexbool or same types as to_replace, default FalseWhether to i...