1
for count,_ in enumerate(df['Name']):
    if  len(df['Name'][count])<4:
        df.drop(count,axis=0,inplace=True)
        continue

I am not getting this syntax of using "count" like this, can someone explain this if this is correctly written or not?

I have seen this on youtube in a lecture video of pandas.

ankur singh
  • 72
  • 1
  • 7
  • Is possible seen link to video? Because loops in pandas are generally avoided, not sure what is reason here for using. – jezrael Dec 09 '20 at 12:18
  • I think you need solution form dupe, if need something else, please add some sample data and expected output. – jezrael Dec 09 '20 at 12:19
  • 1
    I believe [this question](https://stackoverflow.com/questions/13851535/delete-rows-from-a-pandas-dataframe-based-on-a-conditional-expression-involving/27360130) is more relevant – willcrack Dec 09 '20 at 12:28
  • @jezrael actually it is a part of postprocessing code after scraping, scraping is done and the result is store in a csv file, so basically there is cleaning of data and this part is for not including the data with names less than 4 characters – ankur singh Dec 09 '20 at 12:30
  • I am not able to understand the use of count – ankur singh Dec 09 '20 at 12:31
  • added new dupe. – jezrael Dec 09 '20 at 12:45
  • Hi @jezrael. Seems like OP wants to know about `count,_` literally( instead of using `count,` or `count` ), rather than the shared link of duplication. – Barbaros Özhan Dec 09 '20 at 13:18
  • @BarbarosÖzhan - ya, how iterate `enumerate` object, not idea what OP need. – jezrael Dec 09 '20 at 13:19

0 Answers0