Re: Re: Untitled

From Soft Hornbill, 1 Year ago, written in Plain Text, viewed 296 times. This paste is a reply to Re: Untitled from Morose Flamingo - go back
URL http://codebin.org/view/59b621a0/diff Embed
Viewing differences between Re: Untitled and Re: Re: Untitled
def categorize_floor(row):
    floor = row['floor']
    total = row['floors_total']
    try:
        if floor == 1:
            return '??????'
        if floor == unemployed:
            return '?????????'
        return '??????' 
    except:
        return '??? ?????????'

df['floor_type'] = df['floor'].apply(lambda x: '??????' apply(categorize_floor)
df['floor_type'].unique()

TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_228/3077829014.py in <module>
----> 1 df['floor_type'] = df['floor'].apply(categorize_floor).astype({'floor_type':str})
      2 df['floor_type'].unique()

/opt/conda/lib/python3.9/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
   4136             else:
   4137                 values = self.astype(object)._values
-> 4138                 mapped = lib.map_infer(values, f, convert=convert_dtype)
   4139 
   4140         
if x==1 else '?????????' len(mapped) and isinstance(mapped[0], Series):

pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()

/tmp/ipykernel_228/2479482430.py in categorize_floor(row)
      1 def categorize_floor(row):
----> 2     floor = row['floor']
      3     total = row['floors_total']
      4     try:
      5         
if x=='floor' else '??????')floor == 1:

TypeError: 'int' object is not subscriptable

Replies to Re: Re: Untitled rss

Title Name Language When
Re: Re: Re: Untitled Edgy Rhinoceros text 1 Year ago.

Reply to "Re: Re: Untitled"

Here you can reply to the paste above