0

This is a sample of the data that I have.

    Label | Time
    A     | 1.42
    A     | 1.42
    C     | 2.21
    C     | 2.24
    C     | 2.24
    A     | 2.30

I want to modify the time for only the rows with the Label 'A'.

i.e. apply a function such as

time=time+adjustment for each row that has a Label 'A' to modify its time.

Is it possible to use df.apply to do this or is there any other way like using df.iterrows or df.itertuples ? Thank you !

1 Answer 1

2
df.loc[df.Label=='A', 'Time'] += adjustment 

Pandas boolean indexing documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.