Reputation: 7255
Here's my code
actual = actual.apply(lambda x:x.lower())
Here's the error
/.local/lib/python3.6/site-packages/pandas/core/frame.py in apply(self, func, axis, raw, result_type, args, **kwds)
7550 kwds=kwds,
7551 )
-> 7552 return op.get_result()
7553
7554 def applymap(self, func) -> "DataFrame":
~/.local/lib/python3.6/site-packages/pandas/core/apply.py in get_result(self)
183 return self.apply_raw()
184
--> 185 return self.apply_standard()
186
187 def apply_empty_result(self):
~/.local/lib/python3.6/site-packages/pandas/core/apply.py in apply_standard(self)
274
275 def apply_standard(self):
--> 276 results, res_index = self.apply_series_generator()
277
278 # wrap results
~/.local/lib/python3.6/site-packages/pandas/core/apply.py in apply_series_generator(self)
303 for i, v in enumerate(series_gen):
304 # ignore SettingWithCopy here in case the user mutates
--> 305 results[i] = self.f(v)
306 if isinstance(results[i], ABCSeries):
307 # If we have a view on v, we need to make a copy because
<ipython-input-94-4585873426da> in <lambda>(x)
1 import pandas as pd
2 actual = pd.read_csv("Data Rumah Sakit.csv", error_bad_lines=False, sep = ";")
----> 3 actual = actual.apply(lambda x:x.lower())
4 actual["Rumah Sakit"] = actual["Rumah Sakit"].str.replace('[^\w\s]','')
~/.local/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)
5139 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5140 return self[name]
-> 5141 return object.__getattribute__(self, name)
5142
5143 def __setattr__(self, name: str, value) -> None:
AttributeError: 'Series' object has no attribute 'lower'
Upvotes: 0
Views: 5943
Reputation:
Use .str.lower
instead of just .lower
:
actual = actual.apply(lambda x:x.str.lower())
Upvotes: 3