I have NLTK installed and it is going me error Resource punkt not found. Please use the NLTK Downloader to obtain the resource: import nltk nltk.download(‘punkt’) For more information see: https://www.nltk.org/data.html Attempted to load tokenizers/punkt/PY3/english.pickle Searched in: – …
Tag: python
Changing the border width of a plot
I have a script to create an easy plot, but I would like to change the border width because it is a little bit transparent. How can I do this? With images is clearer the my problem Answer I changed the size of your plot because it was way too huge for me to work with, just FYI. What you
Find Function in Python
I’ve made this code but it is not acting how I was expecting: Basically I read a .pcap file which can be full of information or empty and I’m looking for a word inside each raw. If it is found I start some operation on this string in order to reach a desidered position inside the string. I noticed…
Manipulating files using Python
My old friend and I have been trying to save our chat histories recently for the nostalgia and the memories. Google chat history saves in a latest-oldest order. I’d like to make it to oldest-latest as well as change the pattern of the text. Any idea how I can implement this in Python? For reference this…
Groupby several columns, summing them up based on the presence of a sub-string
Context: I’m trying to sum all values based in a list only if they start with or contain a string So with a config file like this: And a dataframe like this: How can I group by if they all start by a given substring present on the granularity_suffix_list? Desired output: Attempts: I was trying this: But…
How do I log tqdm console output to a file in Python?
I’m working on a task that requires me to log the console output of tqdm to a file. Using the below snippet tqdm shows progress bars in the console. I used the file parameter to log the output to a file like this: and I’m able to achieve my expected output. However when I use the file param, tqdm …
How can i save the name of objects in python in specific order?
I am trying to save the name of objects as image in specific order. Like if there are seven objects detected in image and their names are [chair, tv, bed, chair ,bed, chair, chair]. I want that it should be saved as [chair.png, chair1.png, chair2.png, chair3.png, bed.png, bed1.png, tv.png]. No matter what obj…
How to discriminate between graphs in python?
I need to discriminate between 2 different graphs in python. Graphs are show below. So, I want to divide these graphs into two categories, A or B. I want to use a property that can be used to discriminate between the two. If the user gives data set for GRAPH A or similar to GRAPH A, the output should be
Python, plot matrix diagonal elements
I have an 120×70 matrix of which I want to graph diagonal lines. for ease of typing here, I will explain my problem with a smaller 4×4 matrix. index 2020 2021 2022 2023 0 1 2 5 7 1 3 5 8 10 0 1 2 5 3 1 3 5 8 4 I now want to graph for example
Regex to match a list of one or more comma-separated words, unless the string ends in a comma
I have written the following regex long time ago that must match at least 3 words and works in both Latin and Cyrillic characters : regex = ‘([^ ,;d]{2,}[ ,;]{1,}){2,}[^ ,;d]{2,}’ I would like to rewrite it to match hello but fail to match hello, because of the comma. However, I would still like i…