How to raise index error in Pandas on a Windows machine? - python

I am using pandas_dedupe library. I get this error when I try to run on a Windows machine, but this same code runs fine on a Mac.
import pandas as pd
import pandas_dedupe as pdd
df=pd.read_csv('sample.csv')
df=pdd.dedupe_dataframe(df,['firstname','lastname','gender','zipcode','address'])
df.to_csv('sample_deduped.csv')
df=df[df['cluster id'].isnull() | ~df[df['cluster id'].notnull()].duplicated(subset='cluster id',keep='first')]
df.to_csv('sample_deuped_removed.csv')
Here are the logs in case you want to have a look:
Traceback (most recent call last):
File "C:/Users/vikas.mittal/Desktop/python projects/untitled2/deduplication.py", line 10, in <module>
df=pdd.dedupe_dataframe(df,['firstname','lastname','gender','zipcode','address'])
File "C:\Users\vikas.mittal\Desktop\python projects\untitled2\venv\lib\site-packages\pandas_dedupe\dedupe_dataframe.py", line 213, in dedupe_dataframe
sample_size)
File "C:\Users\vikas.mittal\Desktop\python projects\untitled2\venv\lib\site-packages\pandas_dedupe\dedupe_dataframe.py", line 72, in _train
dedupe.consoleLabel(deduper)
File "C:\Users\vikas.mittal\Desktop\python projects\untitled2\venv\lib\site-packages\dedupe\convenience.py", line 36, in consoleLabel
uncertain_pairs = deduper.uncertainPairs()
File "C:\Users\vikas.mittal\Desktop\python projects\untitled2\venv\lib\site-packages\dedupe\api.py", line 714, in uncertainPairs
return self.active_learner.pop()
File "C:\Users\vikas.mittal\Desktop\python projects\untitled2\venv\lib\site-packages\dedupe\labeler.py", line 323, in pop
raise IndexError("No more unlabeled examples to label")
IndexError: No more unlabeled examples to label
Process finished with exit code 1

Related

how to make pyomo lib portable?

I want to know how to make use of pyomo in my program which call the python interpreter to exe some pyomo scripts, but it shows that:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\LL\Desktop\face\face\Release\lib\site-packages\pyomo\environ\__init__.py", line 76, in <module>
_import_packages()
File "C:\Users\LL\Desktop\face\face\Release\lib\site-packages\pyomo\environ\__init__.py", line 73, in _import_packages
pkg.load()
File "C:\Users\LL\Desktop\face\face\Release\lib\site-packages\pyomo\opt\plugins\__init__.py", line 12, in load
import pyomo.opt.plugins.driver
File "C:\Users\LL\Desktop\face\face\Release\lib\site-packages\pyomo\opt\plugins\driver.py", line 14, in <module>
import pyomo.scripting.pyomo_parser
File "C:\Users\LL\Desktop\face\face\Release\lib\site-packages\pyomo\scripting\pyomo_parser.py", line 84, in <module>
description=doc, epilog=epilog, formatter_class=CustomHelpFormatter )
File "C:\Users\LL\Desktop\face\face\Release\lib\argparse.py", line 1647, in __init__
prog = _os.path.basename(_sys.argv[0])
IndexError: list index out of range
pyinstaller doesn't support secondary imports. You have to specify hidden imports of pyomo components in your .spec file

How to use dates in the yahoo_fin Python Package

I recently installed yahoo_fin and I tired the following example:
get_calls('NFLX' ')
It worked. I then tired the following:
get_calls('NFLX', '11/8/2019')
It failed. Here is what I got:
get_calls('NFLX', '11/8/2019')
Traceback (most recent call last):
File "", line 1, in
get_calls('NFLX', '11/8/2019')
File "C:\Users\rsher\Anaconda3\lib\site-packages\yahoo_fin\options.py", line 48, in get_calls
options_chain = get_options_chain(ticker, date)
File "C:\Users\rsher\Anaconda3\lib\site-packages\yahoo_fin\options.py", line 32, in get_options_chain
tables = pd.read_html(site)
File "C:\Users\rsher\Anaconda3\lib\site-packages\pandas\io\html.py", line 906, in read_html
keep_default_na=keep_default_na)
File "C:\Users\rsher\Anaconda3\lib\site-packages\pandas\io\html.py", line 743, in _parse
raise_with_traceback(retained)
File "C:\Users\rsher\Anaconda3\lib\site-packages\pandas\compat__init__.py", line 344, in raise_with_traceback
raise exc.with_traceback(traceback)
ValueError: No tables found
I am using version 3.6.3 of Python and I am also using Spyder.
Am I doing something wrong? Do you think I have found a bug?
I updated my version of yahoo_fin. Not really sure it was out of date. I now get the following error messages when I run the command: get_calls("nflx", "1/31/20")
Traceback (most recent call last):
File "", line 1, in
get_calls("nflx", "1/31/20")
File "C:\Users\rsher\Anaconda3\lib\site-packages\yahoo_fin\options.py", line 48, in get_calls
options_chain = get_options_chain(ticker, date)
File "C:\Users\rsher\Anaconda3\lib\site-packages\yahoo_fin\options.py", line 32, in get_options_chain
tables = pd.read_html(site)
File "C:\Users\rsher\Anaconda3\lib\site-packages\pandas\io\html.py", line 906, in read_html
keep_default_na=keep_default_na)
File "C:\Users\rsher\Anaconda3\lib\site-packages\pandas\io\html.py", line 743, in _parse
raise_with_traceback(retained)
File "C:\Users\rsher\Anaconda3\lib\site-packages\pandas\compat__init__.py", line 344, in raise_with_traceback
raise exc.with_traceback(traceback)
ValueError: No tables found
It should work the way you have it.
from yahoo_fin.options import get_calls
get_calls("nflx", "1/31/20")
Are you using the most recent version of yahoo_fin? It should be (as of this writing) version 0.8.4. Another possible issue is that there could have been a problem with Yahoo Finance's page for that option chain at that particular time.

What is the 'rdt' object in the error: 'KeyError: "Unable to open object (Object 'rdt' doesn't exist)"?

I am trying to execute the following code
impot spacepy.time as spt
import spacepy.omni as om
ticks = spt.Ticktock(['2002-02-02T12:00:00', '2002-02-02T12:10:00'], 'ISO')
d = om.get_omni(ticks)
d.tree(levels=1)
that is the example at the spacepy documentation.
I got the error:
Traceback (most recent call last):
File "<ipython-input-28-bd1a52c0010b>", line 1, in <module>
data = om.get_omni(ticks)
File "/usr/local/lib/python2.7/dist-packages/spacepy-0.1.6-py2.7.egg/spacepy/omni.py", line 252, in get_omni
enval, stval = omnirange(dbase=ldb)[1], omnirange(dbase=ldb)[0]
File "/usr/local/lib/python2.7/dist-packages/spacepy-0.1.6-py2.7.egg/spacepy/omni.py", line 377, in omnirange
start, end = hfile['RDT'][0], hfile['RDT'][-1]
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2684)
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2642)
File "~/.local/lib/python2.7/site-packages/h5py/_hl/group.py", line 166, in __getitem__
oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2684)
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2642)
File "h5py/h5o.pyx", line 190, in h5py.h5o.open (/tmp/pip-4rPeHA-build/h5py/h5o.c:3570)
KeyError: "Unable to open object (Object 'rdt' doesn't exist)"
I don't know how to fix this.
The same problem occur when executing other SpacePy codes.
If you run SpacePy for the first time, a special dataset of OMNI data (more details on it here) needs to be downloaded. To obtain it, simply execute:
import spacepy
spacepy.toolbox.update()
For this function to work properly, you have to make sure that all dependencies according to the Installation Guideline are met - especially the NASA CDF library is needed.

Training py_faster_rcnn on VOC dataset with one class

I am using py_faster_rcnn to train the system for one class ('person'). Originally, it gave me an assertion error similar to this post
How to train new fast-rcnn imageset
So I made the following changes to my imdb.py file:
for b in range(len(boxes)):
if boxes[b][2] < boxes[b][0]:
boxes[b][0] = 0
assert (boxes[:,2] >= boxes[:,0]).all()
After the above changes, I get this new error. Has anyone come across this error or what may I be doing wrong?
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "./tools/train_faster_rcnn_alt_opt.py", line 130, in train_rpn
max_iters=max_iters)
File "/home/microway/test/pytest/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 134, in train_net
pretrained_model=pretrained_model)
File "/home/microway/test/pytest/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 53, in __init__
self.solver.net.layers[0].set_roidb(roidb)
File "/home/microway/test/pytest/py-faster-rcnn/tools/../lib/roi_data_layer/layer.py", line 68, in set_roidb
self._shuffle_roidb_inds()
File "/home/microway/test/pytest/py-faster-rcnn/tools/../lib/roi_data_layer/layer.py", line 26, in _shuffle_roidb_inds
widths = np.array([r['width'] for r in self._roidb])
KeyError: 'width'

OSError: Result too large

I'am playing around with scapy but i cant get it to work. I tried different code's but all gave me the same output:
Traceback (most recent call last):
File "<module1>", line 7, in <module>
File "C:\Python26\lib\site-packages\scapy\sendrecv.py", line 357, in srp
s = conf.L2socket(iface=iface, filter=filter, nofilter=nofilter, type=type)
File "C:\Python26\lib\site-packages\scapy\arch\pcapdnet.py", line 313, in __init__
self.outs = dnet.eth(iface)
File "dnet.pyx", line 112, in dnet.eth.__init__
OSError: Result too large
Iam using python 2.6 with all dependencies installed for scapy.
How to fix this?

Categories