Skip to content
Advertisement

Automatically change variable coming into function to string

Is there a way to automatically change the type of a variable when it arrives at a function, eg: I know this code won’t work, but it’s just to explain my question. I also know I can just do x = my_func(str(x)), but I specifically want to make sure all variables coming into function will be string. Answer The simplest

how to print first name, last name and birthday in python?

I’m trying to print first name, last name and birthday, so how i could do it? Here’s my code: Output should be like this: last_name first_name birthday Cawthorn David 1995-08-01 Answer First add parse_dates to read_csv for datetimes: Then if need filter by minimal birthday and columns in list use DataFrame.loc: For all columns use boolean indexing:

Processing files in sorted order

I have 67 images in a directory with names as: Files are jpg files Im_260x_y where x is the number of images 1..67, y are 0, 1, 4, 8, 16, 32, 64, 128, 258. These files are randomly stored in the directory. I want to process the files in sorted order (same order which I have written above i.e Image

Why is the turtle not turning?

My turtle won’t move with my key press. When you remove the self.forward part, it turns just fine, but when it moves it doesn’t work. How can I make it so that turtle turns while it is moving. Also, what was it that didn’t work in my code before. Also, the image labeled backround isn’t loading. How do I fix

Scrapy can’t find items

I am currently still learning Scrapy and trying to work with pipelines and ItemLoader. However, I currently have the problem that the spider shows that Item.py does not exist. What exactly am I doing wrong and why am I not getting any data from the spider into my pipeline? Running the Spider without importing the items works fine. The Pipeline

Using pyspark.sql.functions without sparkContext import problem

I have situation which can be trivialized to example with two files. filters.py main.py It appears, that F.col object cannot be created without active sparkSession/sparkContext object, so import fails. Is there any way to keep filters separated from other files and how i can import them? My situation is a little bit more complicated, this filters is used in many

What does site_name & site_url by connection to tableau sever mean?

Hello dear community! I need to write (my first) python script, which should download many views from one tableau dashboard and then save it in one excel-file. I have a problem with the connection to the tableau server with tableau-api-lib. I found this code and have a question: What means site_name and site_url? Is it the url of dashboard? If

Python – Output hostname and config

I have a script that runs through a list of hostnames/IPs and outputs to a csv “hostname, output”, in the same cell. I need that the Hostname stays in cell A1, and the Output stays on Cell B1 (and so on – A2 B2 etc) Can you help me? The code is this: Answer I need that the Hostname stays

Advertisement