I have a DataFrame for which
hub2['time'] = pd.to_datetime(hub2.timestamp)
works, but when I write
hub2 >> mutate(time=pd.to_datetime(X.timestamp))
with https://github.com/kieferk/dfply
I get the error
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "[...]/lib/python2.7/site-packages/pandas/util/decorators.py", line 91, in wrapper
return func(*args, **kwargs)
File "[...]/lib/python2.7/site-packages/pandas/tseries/tools.py", line 419, in to_datetime
elif isinstance(arg, ABCSeries):
File "[...]/lib/python2.7/site-packages/pandas/types/generic.py", line 9, in _check
return getattr(inst, attr, '_typ') in comp
TypeError: __nonzero__ should return bool or int, returned Call
Why is that?
Related
Traceback (most recent call last):
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\arrays\datetimelike.py", line 1008, in _cmp_method
other = self._validate_comparison_value(other)
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\arrays\datetimelike.py", line 539, in _validate_comparison_value
raise InvalidComparison(other) from err
pandas.core.arrays.datetimelike.InvalidComparison: 2022-08-01 00:00:00
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\Algorithmic Trading Proejct\Project\stock_strategies\Test\pyfolio_test.py", line 20, in
qs.reports.full(df['pct'])
File "C:\Users\shiri\anaconda3\lib\site-packages\quantstats\reports.py", line 302, in full
metrics(returns=returns, benchmark=benchmark,
File "C:\Users\shiri\anaconda3\lib\site-packages\quantstats\reports.py", line 518, in metrics
metrics['MTD %'] = comp_func(df[df.index >= _dt(today.year, today.month, 1)]) * pct
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\ops\common.py", line 70, in new_method
return method(self, other)
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\arraylike.py", line 60, in ge
return self._cmp_method(other, operator.ge)
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 6685, in _cmp_method
result = op(self._values, other)
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\ops\common.py", line 70, in new_method
return method(self, other)
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\arraylike.py", line 60, in ge
return self._cmp_method(other, operator.ge)
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\arrays\datetimelike.py", line 1010, in _cmp_method
return invalid_comparison(self, other, op)
File "C:\Users\shiri\anaconda3\lib\site-packages\pandas\core\ops\invalid.py", line 34, in invalid_comparison
raise TypeError(f"Invalid comparison between dtype={left.dtype} and {typ}")
TypeError: Invalid comparison between dtype=datetime64[ns, America/Sao_Paulo] and datetimeenter code here
CODE:-
from pyTwistyScrambler import scrambler333
scrambler333.get_WCA_scramble()
Result:-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyTwistyScrambler\__init__.py", line 8, in trimmed_func
return func(*args, **kwargs).strip()
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyTwistyScrambler\scrambler333.py", line 8, in get_WCA_scramble
return _333_SCRAMBLER.call("scramble_333.getRandomScramble")
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_abstract_runtime_context.py", line 37, in call
return self._call(name, *args)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 92, in _call
return self._eval("{identifier}.apply(this, {args})".format(identifier=identifier, args=args))
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 78, in _eval
return self.exec_(code)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_abstract_runtime_context.py", line 18, in exec_
return self._exec_(source)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 88, in _exec_
return self._extract_result(output)
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\execjs\_external_runtime.py", line 167, in _extract_result
raise ProgramError(value)
execjs._exceptions.ProgramError: SyntaxError: Expected identifier, string or number
I want to make a Rubiks cube scrambler but this module is not working, please help
I was trying to run an R function through python's rpy2:
def gph(input1):
frac = rpackages.importr('fracdiff')
a = robjects.r(f'''
fdGPH({input1})
''')
print(a)
it returns an error however:
Traceback (most recent call last):
File "C:\Users\************\mainpage.py", line 168, in update_output
analiza_statystyczna.gph()
File "C:\Users\************\analiza_statystyczna.py", line 151, in gph
a = robjects.r(f'''
File "C:\Users\************\lib\site-packages\rpy2\robjects\__init__.py", line 450, in __call__
p = rinterface.parse(string)
File "C:\Users\************\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 45, in _
cdata = function(*args, **kwargs)
File "C:\Users\************\lib\site-packages\rpy2\rinterface.py", line 108, in parse
res = _rinterface._parse(robj.__sexp__._cdata, num, rmemory)
File "C:\Users\************\lib\site-packages\rpy2\rinterface_lib\_rinterface_capi.py", line 652, in _parse
raise RParsingError('Parsing status not OK',
rpy2.rinterface_lib._rinterface_capi.RParsingError: Parsing status not OK - PARSING_STATUS.PARSE_ERROR
What am I doing wrong?
I'm importing the pltlib on Python3.7.5 by from imview.lib import pltlib.
Then I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bowen/.local/lib/python3.7/site-packages/imview/lib/pltlib.py", line 15, in <module>
cpt_rainbow = gmtColormap.get_rainbow()
File "/home/bowen/.local/lib/python3.7/site-packages/imview/lib/gmtColormap.py", line 21, in get_rainbow
fn = write_rainbow_cpt()
File "/home/bowen/.local/lib/python3.7/site-packages/imview/lib/gmtColormap.py", line 375, in write_rainbow_cpt
N 255 0 0""")
File "/usr/lib/python3.7/tempfile.py", line 620, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
I also check the source code here: github.com/python/cpython/blob/3.7/Lib/tempfile.py
But it seems that my tempfile.py is correct, so why this error happen?
I am trying to apply weights of evidence transformation to my data. I am trying to bin my data with the sc.woebin command, however, this: "sequence item 0: expected str instance, int found" error keeps on showing up. I have no clue as to what i could be doing wrong?
I have no clue as to why is it not working.I have tried different server, switching it up a bit, but i don't know what exactly is the problem and what exactly the error means in my case.
bins = sc.woebin(train, y = 'BAD',
min_perc_fine_bin=0.02,
min_perc_coarse_bin=0.05,
stop_limit=0.1,
max_num_bin=8,
method='tree')
The expected result should be of it just processing the data. However, following is the actual result.
"""
"""
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3.6/multiprocessing/pool.py", line 47, in starmapstar
return list(itertools.starmap(args[0], args[1]))
File "/usr/local/lib/python3.6/dist-packages/scorecardpy/woebin.py", line 702, in woebin2
stop_limit=stop_limit, max_num_bin=max_num_bin, breaks=breaks, spl_val=spl_val)
File "/usr/local/lib/python3.6/dist-packages/scorecardpy/woebin.py", line 486, in woebin2_tree
binning_tree = woebin2_tree_add_1brkp(dtm, initial_binning, min_perc_coarse_bin, bestbreaks)
File "/usr/local/lib/python3.6/dist-packages/scorecardpy/woebin.py", line 446, in woebin2_tree_add_1brkp
bin_add_1bst = binning_add_1bst(initial_binning, bestbreaks)
File "/usr/local/lib/python3.6/dist-packages/scorecardpy/woebin.py", line 423, in binning_add_1bst
.agg({'good':sum, 'bad':sum, 'bin':lambda x:'%,%'.join(x)}).reset_index()\
File "/usr/local/lib/python3.6/dist-packages/pandas/core/groupby/generic.py", line 1315, in aggregate
return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/groupby/generic.py", line 186, in aggregate
result, how = self._aggregate(arg, _level=_level, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/base.py", line 498, in _aggregate
result = _agg(arg, _agg_1dim)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/base.py", line 449, in _agg
result[fname] = func(fname, agg_how)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/base.py", line 432, in _agg_1dim
return colg.aggregate(how, _level=(_level or 0) + 1)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/groupby/generic.py", line 773, in aggregate
return self._python_agg_general(func_or_funcs, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/groupby/groupby.py", line 856, in _python_agg_general
return self._python_apply_general(f)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/groupby/groupby.py", line 707, in _python_apply_general
self.axis)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/groupby/ops.py", line 190, in apply
res = f(group)
File "/usr/local/lib/python3.6/dist-packages/pandas/core/groupby/groupby.py", line 844, in <lambda>
f = lambda x: func(x, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/scorecardpy/woebin.py", line 423, in <lambda>
.agg({'good':sum, 'bad':sum, 'bin':lambda x:'%,%'.join(x)}).reset_index()\
TypeError: sequence item 0: expected str instance, int found
"""
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
<ipython-input-209-aa1b22b28748> in <module>()
4 stop_limit=0.1,
5 max_num_bin=10,
----> 6 method='tree')
2 frames
/usr/lib/python3.6/multiprocessing/pool.py in get(self, timeout)
642 return self._value
643 else:
--> 644 raise self._value
645
646 def _set(self, i, obj):
TypeError: sequence item 0: expected str instance, int found
EDIT: This is what my train looks like:
1