Category "python"

Error "fix_county_string(s) NameError: name 's' is not defined." I am trying to fix all counties in the file

Consider: def fix_county_string(s): """ Insert Docstring """ fp = open("michigan_COVID_08_24_21.txt", "r") fp.readline() for line in fp:

Pytorch Forecasting: Loading a custom dataset

I'm trying to load a custom dataset to PyTorch Forecasting by modifying the example given in this Github repository. However I'm stuck at instantiating the Time

How do I filter models from the Django admin sidebar while keeping them on their children's change page form?

I have a setup that looks like this: Because 'Charities' and 'Interventions' aren't meant to be edited except from the Evaluations and Max Impact Fund Grants p

Initializing an sql query as a dataclass

The goal is to achieve the selected columns in SQL based on the some manual classification of the fields, e.g. from dataclasses import dataclass @dataclass cl

Passing a trained model to another function in airflow

So I want to use airflow to display my model training. I created a model in a python function and now I want to pass it to another function which will train it.

Sort by key (Month) using RDDs in Pyspark

I have this RDD and wanna sort it by Month (Jan --> Dec). How can i do it in pyspark? Note: Don't want to use spark.sql or Dataframe. +-----+-----+ |Month|co

BS4 - 'NoneType' object has no attribute 'findAll' when scanning spans on amazon page

I'm following a Udemy course on learning BS4 and it seems to be a bit outdated so I'm having trouble with this part. The objective is to scrape the price of thi

How to select all columns whose names start with X in a pandas DataFrame

I have a DataFrame: import pandas as pd import numpy as np df = pd.DataFrame({'foo.aa': [1, 2.1, np.nan, 4.7, 5.6, 6.8], 'foo.fighters': [0

How to get real mouse movement, not based on cursor position (python)

Im using windows and python So I want to make a macro in a game, but the game always centers your mouse at the center of the screen. Every mouse movement algori

Can't install pyenv 3.8.5 on MacOS Big Sur with M1 chip?

I am trying to run pyenv install 3.8.5 but keep getting the error below: python-build: use [email protected] from homebrew python-build: use readline from homebrew Do

Retrieving data from the Air Quality Index (AQI) website through the API and only recieving small nr. of stations

I'm working on a personal project and I'm trying to retrieve air quality data from the https://aqicn.org website using their API. I've used this code, which I'v

Defect in linked list in Python

class Node: def __init__(self,data): self.data=data self.next=None head=Node(5) trys=head trys=trys.next trys=Node(7) print(head.nex

Solidity - ImportError: cannot import name 'VRFCoordinatorMock' from 'brownie'

Would really appreciate any help on this error. I've tried several things and reviewed the contracts for VRF, but I can't seem to figure it out. All the other t

What do the brackets in 'turtle.pen()' do? What are they supposed to contain?

So recently I was planning to write a code using turtle graphics and I had a question. What do the brackets in t = turtle.Pen() mean? What are they supposed to

open file (e.g. right click/ open with) event for python3 script on a mac

I would like my python3 script to react to an open file event. Is there any way to achieve that? The following python3 script is named example #!/path/to/python

How to slice a nested list twice?

With a nested list like: ex_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] I need to be able to slice this list for: [[1, 2], [4, 5]] I've been trying: list(ex_list

How to do rolling sum with conditional window criteria on different index levels in Python

I want to do a rolling sum based on different levels of the index but am struggling to make it a reality. Instead of explaining the problem am giving below the

What is wrong with this inkscape extension?

I am not a programmer. I used to use an inkscape extension that was designed to change the path in inkscape to Gcode. Recently this extension stopped working gi

How can I wrap a python function in a way that works with with inspect.signature?

Some uncontroversial background experimentation up front: import inspect def func(foo, bar): pass print(inspect.signature(func)) # Prints "(foo, bar)" like

Why is Guild.get_channel returning a none object sometimes in discord.py

So i got this code, but the get_channel often returns a none object but sometime it replies the discord channel object. Why is this like that? Is there a better