2

How to partially split a dataset from row indexes, and column names or column indexes. I tried this df.loc[[1,2,34,'name']] = 100 and df.iloc[np.where(df.loc[,'name']<100)]=100 this do not work. Need help, thank you!

data sample:

>> df

>>    name  lag
  0   100.0 0.000000
  1   80.0  0.011161
  2   255.0 0.022321
  3   93.0  0.033482
  4   100.0  0.044643
  5   9.8  0.055804
  6   29.0  0.066964

1
  • Can you ad some small data sample to question? Commented Mar 29, 2021 at 9:36

1 Answer 1

3

If need set index values 1,2,34 and columns name name to 100 use:

df.loc[[1,2,34],'name'] = 100

If need set by mask use:

df.loc[df['name']<100, 'name']=100

#for set another column
df.loc[df['name']<100, 'lag']=100
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.