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
Suppose we want to cap values in a dataframe of shape (6,5).
importpandasaspd,numpyasnp# WORKS WITH DF OF SHAPE (6,5)ix=pd.date_range('1/1/2015',periods=6,freq='D')
df0=pd.DataFrame(np.random.normal(size=(len(ix),5)),index=ix)
printdf0df1=df0.quantile(q=.5,axis=1)
printdf1df2=df0.where(df0<df1,df1,axis=0)
printdf2
The above code has capped values above the median. For example:
The same failure will take place is we use binary comparison functions.
# IT ALSO FAILS WITH BINARY COMPARISONS# http://pandas.pydata.org/pandas-docs/stable/basics.html#basics-comparedf2=df0.where(df0.lt(df1,axis=0),df1,axis=0)
printdf2
Suppose we want to cap values in a dataframe of shape (6,5).
The above code has capped values above the median. For example:
Now, if we do the same with a squared dataframe, the same code will fail.
For some reason, broadcasting now is done through axis=1, although the argument explicitly asked for axis=0.
The same failure will take place is we use binary comparison functions.
pandas version 0.16.2 and numpy 1.9.2
Thanks!
The text was updated successfully, but these errors were encountered: