TypeError: got multiple values for argument

This happens when a keyword argument is specified that overwrites a positional argument. For example, let’s imagine a function that draws a colored box. The function selects the color to be used and delegates the drawing of the box to another function, relaying all extra arguments. def color_box(color, *args, **kwargs): painter.select_color(color) painter.draw_box(*args, **kwargs) Then the … Read more

Why is there no xrange function in Python3?

Some performance measurements, using timeit instead of trying to do it manually with time. First, Apple 2.7.2 64-bit: In [37]: %timeit collections.deque((x for x in xrange(10000000) if x%4 == 0), maxlen=0) 1 loops, best of 3: 1.05 s per loop Now, python.org 3.3.0 64-bit: In [83]: %timeit collections.deque((x for x in range(10000000) if x%4 == … Read more

pandas: merge (join) two data frames on multiple columns

Try this new_df = pd.merge(A_df, B_df, how=’left’, left_on=[‘A_c1′,’c2’], right_on = [‘B_c1′,’c2’]) https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.html left_on : label or list, or array-like Field names to join on in left DataFrame. Can be a vector or list of vectors of the length of the DataFrame to use a particular vector as the join key instead of columns right_on : … Read more

error UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte

Python tries to convert a byte-array (a bytes which it assumes to be a utf-8-encoded string) to a unicode string (str). This process of course is a decoding according to utf-8 rules. When it tries this, it encounters a byte sequence which is not allowed in utf-8-encoded strings (namely this 0xff at position 0). Since … Read more

Could not find a version that satisfies the requirement tensorflow

The latest requirements for running TensorFlow are documented in the installation documentation. TensorFlow only supports 64-bit Python TensorFlow only supports certain versions of Python (for example, Python 3.6 is not supported) So, if you’re using an out-of-range version of Python (older or newer) or a 32-bit version, then you’ll need to use a different version.