У меня есть следующий код:
df['Variable Name']=df['Variable Name'].replace(' 15 °',' at 15 °', regex=True)
df['Variable Name']=df['Variable Name'].replace(' at at 15 °',' at 15 °', regex=True)
df['Variable Name']=df['Variable Name'].replace(' 0 °',' at 0 °', regex=True)
df['Variable Name']=df['Variable Name'].replace(' at at 0 °',' at 0 °', regex=True)
df['Variable Name']=df['Variable Name'].replace(' 5 °',' at 5 °', regex=True)
df['Variable Name']=df['Variable Name'].replace(' at at 5 °',' at 5 °', regex=True)
И хотелось бы знать, как его сократить. Я пробовал цикл for:
for x in range(0,15,5):
df['Variable Name']=df['Variable Name'].replace(' %s °',' at %s °', x, regex=True)
df['Variable Name']=df['Variable Name'].replace(' at at %s °',' at %s °', x, regex=True)
Но я получаю сообщение об ошибке:
ValueError: For argument "inplace" expected type bool, received type int.
Какой лучший способ сделать это?
Редактировать: Добавлен фрагмент
Variable Name Condition
Density 15 °C (g/mL)
Density 0 °C (g/mL)
Density 5 °C (g/mL)
Calculated API Gravity
Viscosity at 15 °C (mPa.s)
Viscosity at 0 °C (mPa.s)
Viscosity at 5 °C (mPa.s)
Surface tension 15 °C (oil - air)
Interfacial tension 15 °C (oil - water)