List Comprehension on Pandas-Series

Hello everybody!

I’m a bit stuck here… I created a DataFrame from a csv-file, subsetted it and wanted to do a list-comprehension. Everything works fine but the List ends after 99 elements. Does anyhody have an idea?

###Creating List 
df_list = pd.read_csv(file, delimiter=";")
col = 'example'
liste_raw = df_list[col].tolist() #has 112 elements
liste = [i.replace("/","-") for i in liste_raw)] #this list always has 99 elements, no matter how big the input list is

Is there a fundamental mistake in this code? :smiley:

Would be great if anybody could help!

Thank you guys in advance!!!


Are you sure that each row has a “/” or one of those 13 isn’t a null or nan?

Also, is liste a column or a df?
If you want to change each row in a col I think you need to specify the df[col_name] .

1 Like

Hey lisalisaj,

thanks for your response! Yes, I am sure about that.

I just restarted Jupyter Notebook and everything works :smiley:

Thank you again.


1 Like

No, liste is a list generated by list comprehension:

liste = [i.replace("/","-") for i in liste_raw)]

the column is the variable col = 'example'


1 Like