tagged [python]
Comparing two pandas dataframes for differences
Comparing two pandas dataframes for differences I've got a script updating 5-10 columns worth of data , but sometimes the start csv will be identical to the end csv so instead of writing an identical ...
- Modified
- 31 Dec at 14:17
How to delete all instances of a character in a string in python?
How to delete all instances of a character in a string in python? How do I delete all the instances of a character in this string? Here is my code: However, if I run this, this is what happens: ``` >>...
- Modified
- 5 Mar at 02:23
How can I send a message to someone with my telegram bot using their Username
How can I send a message to someone with my telegram bot using their Username I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number...
- Modified
- 15 Jan at 18:38
How to display the first few characters of a string in Python?
How to display the first few characters of a string in Python? I just started learning Python but I'm sort of stuck right now. I have `hash.txt` file containing thousands of malware hashes in MD5, Sha...
- Modified
- 16 Dec at 02:1
Access multiple elements of list knowing their index
Access multiple elements of list knowing their index I need to choose some elements from the given list, knowing their index. Let say I would like to create a new list, which contains element with ind...
- Modified
- 14 Nov at 01:33
Why can't I install python3.6-dev on Ubuntu16.04
Why can't I install python3.6-dev on Ubuntu16.04 I am trying to install `Python 3.6-dev` with this command: but I'm getting this error: Can anyone help? Why am I getting this error and what is
- Modified
- 12 Mar at 22:1
How do I use itertools.groupby()?
How do I use itertools.groupby()? I haven't been able to find an understandable explanation of how to actually use Python's `itertools.groupby()` function. What I'm trying to do is this: - `lxml`- - I...
- Modified
- 29 Jul at 19:19
How do I install the yaml package for Python?
How do I install the yaml package for Python? I have a Python program that uses YAML. I attempted to install it on a new server using `pip install yaml` and it returns the following: Ho
- Modified
- 18 Jan at 21:3
__init__() missing 1 required positional argument
__init__() missing 1 required positional argument I am trying to learn Python. This is a really simple code. All I am trying to do here is to call a class's constructor. Initialize some variables ther...
- Modified
- 4 Mar at 23:17
warning about too many open figures
warning about too many open figures In a script where I create many figures with `fix, ax = plt.subplots(...)`, I get the warning `matplotlib.pyplot.figure` However, I don't understand I get this warn...
- Modified
- 30 Jul at 11:31
Why I get 'list' object has no attribute 'items'?
Why I get 'list' object has no attribute 'items'? Using Python 2.7, I have this list: I'd like to extract values out of it. i.e. `[15, 9, 16]` So I tried: But instead, I get this error: ``` Traceback ...
- Modified
- 27 Nov at 03:34
How to dynamically load a Python class
How to dynamically load a Python class Given a string of a Python class, e.g. `my_package.my_module.MyClass`, what is the best possible way to load it? In other words I am looking for a equivalent `Cl...
- Modified
- 29 Sep at 21:27
Working with TIFFs (import, export) in Python using numpy
Working with TIFFs (import, export) in Python using numpy I need a python method to open and import TIFF images into numpy arrays so I can analyze and modify the pixel data and then save them as TIFFs...
- Modified
- 14 Feb at 20:26
How to convert a hex string to hex number
How to convert a hex string to hex number I want to convert a hex string (ex: `0xAD4`) to hex number, then to add `0x200` to that number and again want to print that number in form of `0x` as a string...
- Modified
- 19 Feb at 12:55
How to use Python requests to fake a browser visit a.k.a and generate User Agent?
How to use Python requests to fake a browser visit a.k.a and generate User Agent? I want to get the content from [this](http://www.ichangtou.com/#company:data_000008.html) website. If I use a browser ...
- Modified
- 7 Dec at 08:54
How to join entries in a set into one string?
How to join entries in a set into one string? Basically, I am trying to join together the entries in a set in order to output one string. I am trying to use syntax similar to the join function for lis...
- Modified
- 30 Jan at 13:27
How to check if a variable is an integer or a string?
How to check if a variable is an integer or a string? I have an application that has a couple of commands. When you type a certain command, you have to type in additional info about something/someone....
- Modified
- 10 May at 18:6
Connection Timeout with Elasticsearch
Connection Timeout with Elasticsearch This simples code is returning t
- Modified
- 18 Jun at 16:50
How do I convert a PIL Image into a NumPy array?
How do I convert a PIL Image into a NumPy array? How do I convert a PIL `Image` back and forth to a NumPy array so that I can do faster pixel-wise transformations than PIL's `PixelAccess` allows? I ca...
- Modified
- 30 Jul at 06:21
Remove list from list in Python
Remove list from list in Python > [Get difference from two lists in Python](https://stackoverflow.com/questions/5305164/get-difference-from-2-lists-python) What is a simplified way of doing this? I ...
- Modified
- 23 May at 12:34
"for line in..." results in UnicodeDecodeError: 'utf-8' codec can't decode byte
"for line in..." results in UnicodeDecodeError: 'utf-8' codec can't decode byte Here is my code, Whenever I run this code it gives the following error: > UnicodeDecodeError: 'utf-8' codec can't decode...
- Modified
- 30 Jan at 16:27
Which is the preferred way to concatenate a string in Python?
Which is the preferred way to concatenate a string in Python? Since Python's `string` can't be changed, I was wondering how to concatenate a string more efficiently? I can write like it: or like this:...
- Modified
- 28 Aug at 17:50
How to get the index with the key in a dictionary?
How to get the index with the key in a dictionary? I have the key of a python dictionary and I want to get the corresponding index in the dictionary. Suppose I have the following dictionary, Is there ...
- Modified
- 31 May at 23:52
How to write a Python module/package?
How to write a Python module/package? I've been making Python scripts for simple tasks at work and never really bothered packaging them for others to use. Now I have been assigned to make a Python wra...
- Modified
- 24 Mar at 12:29
threading.Timer - repeat function every 'n' seconds
threading.Timer - repeat function every 'n' seconds I want to fire off a function every 0.5 seconds and be able to start and stop and reset the timer. I'm not too knowledgeable of how Python threads w...
- Modified
- 13 Jan at 01:14
Python requests module sends JSON string instead of x-www-form-urlencoded param string
Python requests module sends JSON string instead of x-www-form-urlencoded param string I was under the impression that POSTSs using x-www-form-urlencoded specifications should send a URL encoded param...
- Modified
- 28 Oct at 18:25
Saving response from Requests to file
Saving response from Requests to file I'm using [Requests](http://docs.python-requests.org/en/latest/api/) to upload a PDF to an API. It is stored as "response" below. I'm trying to write that out to ...
- Modified
- 20 Feb at 14:46
How to download image using requests
How to download image using requests I'm trying to download and save an image from the web using python's `requests` module. Here is the (working) code I used: Here is the new (non-working) code using...
- Modified
- 30 Oct at 11:14
Python DNS module import error
Python DNS module import error I have been using python dns module.I was trying to use it on a new Linux installation but the module is not getting loaded. I have tried to clean up and install but the...
- Modified
- 8 Feb at 20:36
Python: how to capture image from webcam on click using OpenCV
Python: how to capture image from webcam on click using OpenCV I want to capture and save a number of images from my webcam using OpenCV. This is my code currently: The problem with this is that I do ...
- Modified
- 4 Jan at 09:53
How do I change the string representation of a Python class?
How do I change the string representation of a Python class? In Java, I can override the `toString()` method of my class. Then Java's print function prints the string representation of the object defi...
- Modified
- 6 Nov at 10:4
How can I force division to be floating point? Division keeps rounding down to 0?
How can I force division to be floating point? Division keeps rounding down to 0? I have two integer values `a` and `b`, but I need their ratio in floating point. I know that `a
- Modified
- 13 Oct at 18:12
TypeError: Missing 1 required positional argument: 'self'
TypeError: Missing 1 required positional argument: 'self' I have some code like: But I get an error like: ``` Traceback (most recent call last): File "C:\Users\Dom\Desktop\test\test.py", line 7, in ...
- Modified
- 18 Feb at 20:9
input() error - NameError: name '...' is not defined
input() error - NameError: name '...' is not defined I am getting an error when I try to run this simple script: Let's say I type in "dude", the error I am getting is: ``` line 1, in input_variable ...
- Modified
- 23 Nov at 05:44
Find column whose name contains a specific string
Find column whose name contains a specific string I have a dataframe with column names, and I want to find the one that contains a certain string, but does not exactly match it. I'm searching for `'sp...
- Modified
- 11 Mar at 03:35
Using python Requests with javascript pages
Using python Requests with javascript pages I am trying to use the Requests framework with python ([http://docs.python-requests.org/en/latest/](http://docs.python-requests.org/en/latest/)) but the pag...
- Modified
- 15 Oct at 22:31
Asyncio.gather vs asyncio.wait
Asyncio.gather vs asyncio.wait [asyncio.gather](https://docs.python.org/3/library/asyncio-task.html#asyncio.gather) and [asyncio.wait](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait)...
- Modified
- 1 Aug at 15:48
Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION]
Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION] I am trying to install a Python library using `pip`, getting an SSL error: ``` ~/projects/base pre-master± pip install xdict C...
- Modified
- 21 May at 10:40
Convert png to jpeg using Pillow
Convert png to jpeg using Pillow I am trying to convert png to jpeg using pillow. I've tried several scrips without success. These 2 seemed to work on small png images like this one. [](https://i.stac...
- Modified
- 8 Aug at 14:46
How to uninstall Python 2.7 on a Mac OS X 10.6.4?
How to uninstall Python 2.7 on a Mac OS X 10.6.4? I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the entry from the `PATH` variable by reverting my `.bash_profile`...
- Modified
- 30 Aug at 13:54
The right way to limit maximum number of threads running at once?
The right way to limit maximum number of threads running at once? I'd like to create a program that runs multiple light threads, but limits itself to a constant, predefined number of concurrent runnin...
- Modified
- 14 Oct at 21:44
NLTK python error: "TypeError: 'dict_keys' object is not subscriptable"
NLTK python error: "TypeError: 'dict_keys' object is not subscriptable" I am following instructions for a class homework assignment and I am supposed to look up the top 200 most frequently used words ...
- Modified
- 20 Aug at 08:33
How to create a DataFrame of random integers with Pandas?
How to create a DataFrame of random integers with Pandas? I know that if I use [randn](https://numpy.org/doc/stable/reference/random/generated/numpy.random.randn.html), the following code gives me wha...
- Modified
- 13 Feb at 09:38
Safest way to convert float to integer in python?
Safest way to convert float to integer in python? Python's math module contain handy functions like `floor` & `ceil`. These functions take a floating point number and return the nearest integer below ...
- Modified
- 5 Aug at 18:21
How can I install Python's pip3 on my Mac?
How can I install Python's pip3 on my Mac? I'm trying to install pip3, but I'm not having any luck. Also, I tried `sudo install` and it did not work. How could I install pip3 on my Mac? ``` sudo easy_...
- Modified
- 6 Dec at 07:9
Understanding __get__ and __set__ and Python descriptors
Understanding __get__ and __set__ and Python descriptors I am to understand what Python's descriptors are and what they are useful for. I understand how they work, but here are my doubts. Consider the...
- Modified
- 12 Jun at 01:12
No module named setuptools
No module named setuptools I want to install setup file of twilio. When I install it through given command it is given me an error: > No module named setuptools. Could you please let me know what shou...
- Modified
- 22 Jul at 09:1
How to choose bins in matplotlib histogram
How to choose bins in matplotlib histogram Can someone explain to me what "bins" in histogram are (the [matplotlib hist](http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.hist) function)? An...
- Modified
- 3 May at 02:24
Removing numbers from string
Removing numbers from string How can I remove digits from a string?
What is the correct syntax for 'else if'?
What is the correct syntax for 'else if'? I'm a new Python programmer who is making the leap from 2.6.4 to 3.1.1. Everything has gone fine until I tried to use the 'else if' statement. The interpreter...
- Modified
- 5 Mar at 15:3