I am new to Python, I have a dataframe as shown:

Pls see the image

There are 15 forces acting per element no., and I want to find the maximum value (absolute) from the Strain column for each element no. and save the result to a csv file. There are 'n' number of elements. I just need the largest value and its row label for all elements.

I tried the below code, but it is showing the largest value from both the elements combined. I want it separate for each element no.

Expected Result: Pls see this image. I want output like this

Actual Result: Pls see image

f = pd.read_csv ('ABC.csv')
df1 = df[df['Strain at 0']==df['Strain at 0'].max()]
df1.to_csv('ABCresult2.csv', encoding='utf-8', index=False)

0 Answers