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

Many standard methods do not work (properly) on XDataFrame with hierarchical data #20

Open
mloning opened this issue Jan 17, 2019 · 0 comments

Comments

@mloning
Copy link
Collaborator

mloning commented Jan 17, 2019

# loading some time-series data
from io import BytesIO
from zipfile import ZipFile
from urllib.request import urlopen
from xpandas.data_container import XSeries, XDataFrame
import numpy as np
import pandas as pd

def read_data(file):
    data = file.readlines()
    rows = [row.decode('utf-8').strip().split('  ') for row in data]
    X = pd.DataFrame(rows, dtype=np.float)
    y = X.pop(0)
    ts = XSeries([row for _, row in X.iterrows()])
    X = XDataFrame({'ts1': ts, 'ts2': ts})
    return X, y

url = 'http://www.timeseriesclassification.com/Downloads/GunPoint.zip'
url = urlopen(url)
zipfile = ZipFile(BytesIO(url.read()))
file = zipfile.open('GunPoint_TRAIN.txt')
X, y = read_data(file)

X.mean() # returns empty series rather than mean of series, the same for many other methods like .std(), .median(), etc)

X.apply(np.mean) # breaks

X['ts1'].mean() # breaks 

X['ts1'].apply(np.mean) # works

X['ts1'].apply(np.percentile, args=(25,)) # breaks, does not passes on args 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant