-
- Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Milestone
Description
Originally posted at stackexchange:
http://stackoverflow.com/questions/25811529/setting-values-on-a-subset-of-rows-indexing-boolean-setting/25812825#25812825
Jeff suggested posting here also.
df = DataFrame({'L': ['left', 'right', 'left', 'right'], 'R': ['right', 'left', 'right', 'left'], 'idx': [False, True, False, True], 'num': np.arange(4) }) df1 = df.copy() df2 = df.copy() df3 = df.copy() df4 = df.copy() #1 nothing happens (expected result) df1.loc[df1.idx,['L','R']] = df1.loc[df1.idx,['R','L']] #2 something weird happens df2.loc[df2.idx,['L','R']] = df2[['R','L']]Results below:
In [572]: df Out[572]: L R idx num 0 left right False 0 1 right left True 1 2 left right False 2 3 right left True 3 In [573]: df1 Out[573]: L R idx num 0 left right False 0 1 right left True 1 2 left right False 2 3 right left True 3 In [574]: df2 Out[574]: L R idx num 0 left right False 0 1 left right True 1 2 left right False 2 3 right left True 3INSTALLED VERSIONS ------------------ commit: None python: 2.7.7.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 26 Stepping 5, GenuineIntel byteorder: little LC_ALL: None LANG: None pandas: 0.14.1.dev nose: 1.3.3 Cython: 0.20.1 numpy: 1.8.1 scipy: 0.14.0 statsmodels: 0.5.0 IPython: 2.1.0 sphinx: 1.2.2 patsy: 0.2.1 scikits.timeseries: None dateutil: 1.5 pytz: 2014.3 bottleneck: None tables: 3.1.1 numexpr: 2.3.1 matplotlib: 1.3.1 openpyxl: 1.8.5 xlrd: 0.9.3 xlwt: 0.7.5 xlsxwriter: 0.5.5 lxml: 3.3.5 bs4: 4.3.1 html5lib: None httplib2: None apiclient: None rpy2: None sqlalchemy: 0.9.4 pymysql: None psycopg2: None Metadata
Metadata
Assignees
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves