In a dataframe
df = pd.DataFrame({'c1': ['c10:b', 'c11', 'c12:k'], 'c2': ['c20', 'c21', 'c22']})
c1 c2
0 c10:b c20
1 c11 c21
2 c12:k c22
I'd like to modify the string values of column c1 so that everything after (and including) the colon removes, so it ends up like this:
c1 c2
0 c10 c20
1 c11 c21
2 c12 c22
I've tried slicing
df[’c1’].str[:df[’c1’].str.find(’:’)]
but it doesn't work. How do I accomplish this?