Skip to content
Advertisement

How to split AFTER underscore in Python

I’ve seen a lot of threads that say how to split based on an underscore, but how can we split a string where the split is done after the underscore. So let’s say I have a pandas dataframe with one column: how can I achieve the following output? Thanks in advance. Answer You can split with the _ as a

Translation in discord.py bot doesn’t work

I’ve been trying to make my discord bot translate texts using a module called googletrans. It seems fairly simple and it should have worked without any hassle, or so I thought. So after my import statements, I have translator = Translator(). My following cog code is: But it shows this error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: ‘NoneType’ object has

How to combine multiple files in GCS bucket with Cloud Function trigger

I have 3 files per date per name in this format: ‘nameXX_date’, here’s an example: ‘nameXX_01-01-20’ ‘nameXY_01-01-20’ ‘nameXZ_01-01-20’ where ‘name’ can be anything, and the date is whatever day the file was uploaded (almost every day). I need to write a cloud function that triggers whenever a new file lands in the bucket, that combines the 3 XX,XY,XZ files into

Problem importing fonts with FPDF using python

I’ve been trying to import specialty fonts beyond what is default included with the FPDF package with Python, using the pdf.add_font() command. The code below produces an error of an Undefined font, as though I didn’t just use pdf.add_font(). Below you can find a sample of my code, as well as proof that the relevant fonts are in the directory

Downloading all JS files using Scrapy?

I am trying to crawl a website searching for all JS files to download them. I am new to Scrapy and I have found that I can use CrawlSpider but seems I have an issue with LinkExtractors as my parser is not executed. Answer I found that LinkExtractor has tags and attrs parameters where the default are for ‘a’ and

CSV data to Python dictionary

I wrote my data which was in lists and dicts to a csv file, and when i import the csv file using pd.read_csv(‘file.csv’), everything becomes strings. How can i keep or convert it to its original format? Originally, everything was in a dataframe and then written to a CSV file using df.to_csv(r’./file.csv’). all the rows are strings. Answer This will

Serach List names in a dataframe column pandas

I am trying to match my list of server with the pandas dataframe in the column Server Name if the name in the list matches in the Server Name then print the entire row. there are chances names is the my_List do not match entirely like one of the server name in my_List is tick1001.example.us.com while in Server Name. This

Advertisement