How to remove last n characters from a string in Bash?

First, it’s usually better to be explicit about your intent. So if you know the string ends in .rtf, and you want to remove that .rtf, you can just use var2=${var%.rtf}. One potentially-useful aspect of this approach is that if the string doesn’t end in .rtf, it is not changed at all; var2 will contain … Read more

How can I copy a Python string?

You don’t need to copy a Python string. They are immutable, and the copy module always returns the original in such cases, as do str(), the whole string slice, and concatenating with an empty string. Moreover, your ‘hello’ string is interned (certain strings are). Python deliberately tries to keep just the one copy, as that … Read more

cannot convert the series to

Your error is line 2. df[‘intage’] = int(df[‘age’]) is not valid, you can’t pass a pandas series to the int function. You need to use astype if df[‘age’] is object dtype. Or since you are subtracting two dates, you need to use dt accessor with the days attribute to get the number of days as … Read more