Inside my dataframe:

```
no    pre_code
1     23, 234, 345
2     234, 345
3     23
4     NaN

```

I want to count number of string inside `pre_code` columns, What I have tried so far was:

```
df['count'] = df['pre_code'].astype('str').str.split(',').str.len().fillna(0)

```

but with the code above, it counts NaN as 1. So, I dont get the desired results.

Before, I also have tried this way:

```
df['count'] = df['pre_code'].str.count(',').add(1).fillna(0)

```

Unfortunately, the code above also did not work on my dataframe. It gives me 0 for the single entry string. For your information, I have 2200 rows on my dataframe, and somehow the code could not work perfectly for those number of rows. When I tried for only 5 rows, somehow it worked well.

I expect the result would be like:

```
no    pre_code         count
1     23, 234, 345       3
2     234, 345           2
3     23                 1
4     NaN                0

```

any solution for my case?

thanks in advance.