-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
IndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsWarningsWarnings that appear or should be added to pandasWarnings that appear or should be added to pandasgood first issue
Milestone
Description
-
I have searched the [pandas] tag on StackOverflow for similar questions.
-
I have asked my usage related question on StackOverflow.
Question about pandas
Note: If you'd still like to submit a question, please read this guide detailing how to provide the necessary information for us to reproduce your question.
# Your code here, if applicable
import numpy as np
import pandas as pd
dic = {'A': [1, 4, 1, 4], 'B': [9, 2, 5, 3], 'C': [0, 0, 5, 3]}
df = pd.DataFrame(dic)
df.index = [0, 0, 1, 1]
df1 = df.copy()
df1[:] = np.nan
df1.loc[0]['A'] = df.loc[0]['A']
original df
:
A B C
0 1 9 0
0 4 2 0
1 1 5 5
1 4 3 3
I want to replace the subset of the copy with the subset of original df
:
A B C
0 1 NaN NaN
0 4 NaN NaN
1 NaN NaN NaN
1 NaN NaN NaN
However, it shows no change at all:
A B C
0 NaN NaN NaN
0 NaN NaN NaN
1 NaN NaN NaN
1 NaN NaN NaN
Metadata
Metadata
Assignees
Labels
IndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsWarningsWarnings that appear or should be added to pandasWarnings that appear or should be added to pandasgood first issue