Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rolling_apply and dataframes #8777

Closed
denadai2 opened this issue Nov 10, 2014 · 1 comment
Closed

rolling_apply and dataframes #8777

denadai2 opened this issue Nov 10, 2014 · 1 comment
Labels
API Design Duplicate Report Duplicate issue or pull request Enhancement Groupby Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@denadai2
Copy link

Hello, I'm trying to apply this

from scipy.spatial import distance
def myrolling_apply(df):
    print type(df)
    print df
    print df.dtypes
    a = df['predicted'].values
    b = df['actual'].values
    #dst = distance.euclidean(a,b)
    return(df)

rrbug = pd.read_csv('bug.csv')
rrbug = pd.rolling_apply(rrbug, 24, myrolling_apply)

To this dataframe https://dl.dropboxusercontent.com/u/1118905/bug.csv. I would aspect to have a dataframe BUT df is a ndarray, as you see from the results:

<type 'numpy.ndarray'>
[ 18.038866  18.81628   15.652594  19.418134  23.685213  21.636703
  32.264257  44.563431  63.160193  46.759563  44.06377   45.75921
  57.929419  58.121308  61.65729   59.300808  64.033246  57.590802
  56.642796  53.321256  68.65092   57.555255  39.222144  34.622948]
@jreback
Copy link
Contributor

jreback commented Nov 10, 2014

this is a dupe of #5071

currently a 2-d ndarray is passed. Pls feel free to submit a pull-request to enhance. (You can easily just wrap this in a DataFrame if you want inside your function).

@jreback jreback added API Design Enhancement Groupby Categorical Categorical Data Type Duplicate Report Duplicate issue or pull request Reshaping Concat, Merge/Join, Stack/Unstack, Explode and removed Categorical Categorical Data Type labels Nov 10, 2014
@jreback jreback closed this as completed Nov 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Duplicate Report Duplicate issue or pull request Enhancement Groupby Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

2 participants