You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setitem and getitem reindex DataFrame keys when shapes differ, but do not reindex when shapes are the same and indexes/columns are different
In [68]: df3=p.DataFrame(np.random.randn(5, 2),
....: index=[1.0, 2.5, 3, 4.5, 5.0])
In [69]: key= (df3>0).reindex(df3.index[:-1]) # first four rowsIn [70]: df3[key] =5# key is reindexed because shape does not match (ok)In [71]: df3Out[71]:
011.0-1.5991425.0000002.55.000000-0.1803303.0-0.5682065.0000004.5-0.340465-0.0701055.0-0.4749551.928842In [72]: key=key.reindex(key.index[::-1]) # reverse rows in keyIn [73]: df3[key] =4# key is reindexed because shape does not match (ok)In [74]: df3Out[74]:
011.0-1.5991424.0000002.54.000000-0.1803303.0-0.5682064.0000004.5-0.340465-0.0701055.0-0.4749551.928842In [75]: df3=p.DataFrame(np.random.randn(5, 2),
....: index=[1.0, 2.5, 3, 4.5, 5.0])
In [76]: key= (df3>0) # all rowsIn [77]: df3[key] =5# no reindex requiredIn [78]: df3Out[78]:
011.05.000000-0.2337792.55.000000-0.1419623.0-0.2325515.0000004.5-1.6630345.0000005.0-0.653200-0.365681In [79]: key=key.reindex(key.index[::-1]) # reverse rows in keyIn [80]: df3[key] =4# key is not reindexed, even though rows are reversedIn [81]: df3Out[81]:
011.05.000000-0.2337792.55.0000004.0000003.0-0.2325514.0000004.54.0000005.0000005.04.000000-0.365681
The text was updated successfully, but these errors were encountered:
setitem fails with row slices supported by getitem
setitem fails on boolean indexing unless key is ndarray, while getitem casts appropriately
getitem does not reindex boolean Series key but setitem does
getitem does not allow DataFrame key when columns are MultiIndex, but setitem does
setitem and getitem reindex DataFrame keys when shapes differ, but do not reindex when shapes are the same and indexes/columns are different
The text was updated successfully, but these errors were encountered: