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

Crash of pyvttbl.pivot().to_dataframe() #11

Open
GoogleCodeExporter opened this issue Mar 18, 2015 · 0 comments
Open

Crash of pyvttbl.pivot().to_dataframe() #11

GoogleCodeExporter opened this issue Mar 18, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. make sparse pivot table (e.g. some elements empty)
2. do .to_dataframe() on sparse pivot table
3. crash with message:

Traceback (most recent call last):
  File "pilot-cancelation-report.py", line 148, in <module>
    a.run()
  File "pilot-cancelation-report.py", line 142, in run
    d1 = df.pivot('ks', rows=['duvod_popis'], cols=['zruseno_rok','zruseno_tyden'], aggregate='sum').to_dataframe()
  File "/usr/lib/python2.7/site-packages/pyvttbl-0.5.2.2-py2.7.egg/pyvttbl/base.py", line 2374, in to_dataframe
    df.insert(zip(header, rdata))
  File "/usr/lib/python2.7/site-packages/pyvttbl-0.5.2.2-py2.7.egg/pyvttbl/base.py", line 1554, in insert
    self[k]=np.concatenate((self[k], np.array([v], dtype=self._get_nptype(k))))
TypeError: long() argument must be a string or a number, not 'NoneType'

I have dirty-fixed this with (around line 1553 of base.py):

        elif c - s == set():
            for (k, v) in OrderedDict(row).items():
                if v is None:
                    v = 0
                self[k]=np.concatenate((self[k], np.array([v], dtype=self._get_nptype(k))))
                self.conditions[k].add(v)

(if v is None, let v = 0). But this is only dirty fix.

What is the expected output? What do you see instead?

it should generate DataFrame object.

What version of the product are you using? On what operating system?

0.5.2.2
linux (debian)
python 2.7

Please provide any additional information below.

more info on request, I'm able provide example data, if necessary.

Original issue reported on code.google.com by profa...@gmail.com on 30 Apr 2013 at 12:51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant