Avatar ·

How to rename columns in Pandas df with underscores

📁 Advanced Python Topics, example

a = pd.DataFrame([{'id': 1, 'b': 2, 'Первое имя': ""AA"", 'Второе имя': 2},                  {'id': 1, 'b': 2, 'Первое имя': ""BB"", 'Второе имя': 2},                  {'id': 1, 'b': 4, 'Первое имя': ""AA"", 'Второе имя': 2                    
Avatar ·

The correct answer in your case directly gets the needed string, for example:

#!/usr/bin/env pythonimport timeprint(time.strftime('%Y-%m-%d %H.%M.%S'))

Or, if you need fractions of a second:

#!/usr/bin/env pythonfrom datetime import datetimeprint(datetime.now().strftime('%Y-%m-%d %H.%M.%S.%f'))

Answer to the question in the title

Q: Changing values of string elements in a loop

Strings are immutable in Python

Log in to leave an answer

Blogs