Quantcast
Channel: Active questions tagged python - Stack Overflow
↧

How to use Pandas style objects to format values with a hyperlink based on...

I want to format a Pandas DataFrame with a hyperlink based on the index.import pandas as pddf = (pd.DataFrame([dict(food='bananas', count=33, color='yellow'), dict(food='apples', count=42,...

View Article


Tensorflow images guide not working in Google Colab

I'm trying to run the first guide from Tensorflow in Google Colab.I import the dataset withimport pathlibdataset_url =...

View Article


Get TCP Flags with Scapy

I'm parsing a PCAP file and I need to extract TCP flags (SYN, ACK, PSH, URG, ...).I'm using the packet['TCP'].flags value to obtain all the flags at once.pkts = PcapReader(infile)for p in pkts: F =...

View Article

Best way to store in a structure the args and kwargs for a function/method

Best way to keep args and kwargs for a function/method.I have a function that I need to call with multiple set of arguments, args and kwargs.t.addelement("tas", "alpha", action="pro",...

View Article

FastAPI get user ID from API key

In fastAPI one can simply write a security dependency at the router level and secure an entire part of the URLs.router.include_router( my_router, prefix="/mypath",...

View Article


How do I execute a program or call a system command?

How do I call an external command within Python as if I had typed it in a shell or command prompt?

View Article

Can't Import win32gui and win32ui modules to my project on Python 3.8 32-bit

I am trying to get a screenshot in Python 3.8. When I search in google for the fastest way I found this link.Fastest way to take a screenshot with python on windowsThere is some module needed to...

View Article

Connect to IBM DB2 database using SQLAlchemy

I am trying to connect to a cloud based IBM DB2 database using SQLAlchemy. Using the base ibm_db python library this works :connection_string =...

View Article


How to automatically detect and fix inconsistent categorical data in large...

I’m working on a data science project and facing issues with inconsistent categorical data coming from multiple sources.For example, the same category appears in different forms:"USA", "U.S.A", "United...

View Article


Image may be NSFW.
Clik here to view.

Downloading and accessing data from github python

Hi I'm going through Python for Data analysis and I'd like to analyze the data he goes through in the book. In chapter 9, he uses the data below. However, I'm having a difficult time understanding how...

View Article

Pycharm Couldn't connect to console process

I recently installed Caffe along with OpenCV and other dependencies. Pycharm worked well for 2 days and today I can't start Python Console in Pycharm anymore. I can start python in terminal with no...

View Article

Compare list of dictionary in Robot Framework

I have two Dictionaries of list of dictionary and I want to compare the value of first list dictionary to second list of dictionaryFor example:Dictionary A contains [{Name:C}, {Name:A},...

View Article

Convert Python Request call to PHP (cURL) [closed]

The company I am using has a API I need to use but only gives an example to me in Python.Can someone help me write it in PHP? I think the problem is in the file sending.Here is the Python code:import...

View Article


`ResolutionFailed: Could not resolve ... to a strategy; consider using...

Despite:Registering RandColl2 using st.register_type_strategy with a handler,RandColl2[str, int] and RandColl2[int, str] being instances of types.GenericAlias, andht.str and ht.Str being registered as...

View Article

Xticks by pandas plot, rename with the string

I have this df:df = pd.DataFrame({'A': [1, 2, 3], 'B': [2, 3, 5], 'C': ['name 1', 'name 2', 'name 3']}) A B C0 1 2 name 11 2 3 name 22 3 5 name 3What is it the correct way to plot column A and use...

View Article


Using member functions of a class as LangGraph tools

I'm writing an agent using the LangChain and LangGraph libraries. I want to make my agent able to interact with files but only inside of the local directory, so I am writing a family of tools that are...

View Article

Brightway 'bw2io.import_ecoinvent_release()' failing unless I disable...

I tried to run bw2io.import_ecoinvent_release() to import ecoinvent as I used to, but the function is now stuck in a loop and return error messages indefinitely (see below).What I run:import bw2data as...

View Article


What is the difference between a newline character and actually writing...

See the following:Case 1:Hi\nHelloCase 2:HiHelloBoth of them are found in text files. So, I did some experiments on them to figure out if there are any differences between them:In [1]:...

View Article

How to clear the cache of mpmath? [closed]

Does the function mp.clear_cache() still exist? I was told it does, but I can’t find it. Is there an alternative or workaround to clear the cache in mpmath?Background: mpmath seems to accumulate its...

View Article

Generate full combination without cyclic rotations

I need to generate a binary sequence of a certain length.I use the numpy library to generate combinations. I found the following code:np.array(np.meshgrid(*[[1, 0] for x in range(size)])).T.reshape(-1,...

View Article

How do I subclass argparse.Action to add a custom action?

I have a command line script I'm trying to run that inserts a default value into the Namespace if the value is absent, or takes the supplied argument as is if it's present.So I want to do...

View Article


Image may be NSFW.
Clik here to view.

How to plot unit tangent and unit normal vectors on a parameterized curve?

I am working to practice on some simple parameterized curve given by:import numpy as npimport matplotlib.pyplot as pltfig, ax = plt.subplots(figsize=(6, 3))t = np.linspace(-4, 4, 100)x = ty = t**3 -...

View Article


Remove all nodes that has a particular attribute in networkx

I`m trying to remove all nodes within a Graph that has an specific attribute value.I have seen this: python networkx remove nodes and edges with some conditionBut in that case the degree is a property...

View Article

Cython cannot access cdef attributes from one cdef class to another

In the pxd file I am declaring the cdef class Offset:cdef struct Internals: size_t x size_t y bint x_is_percent bint y_is_percentcdef class Offset: # Internal struct cdef Internals _internals ...Here's...

View Article

Curl completing too late for following instruction

I updated my Fedora OS for the first time in many years, and the python version updated as well. This necessitated some minor changes to my existing code (naked print no longer allowed, <>...

View Article


DB corrupted in Odoo 13

I have a running production instance with existing data in my production database. Recently, I encountered an error, and upon investigation, I discovered that some core modules were unexpectedly...

View Article

Fetch data from https://www.sofascore.com/?

This is my python code using on ubuntu to try fetch and extract data fromhttps://www.sofascore.com/I create this test code before using on E2 device in my plugin# python3 -m venv venv# source...

View Article

Python Module or Library with multiple Thermal printer support

I am currently printing thermal receipts with small python code prints thermal receipts for my billing application.What I am currently doing isBuild the receipt to PDF using Reportlabthen convert pdf...

View Article

Check if an element is present in a StructType in a Spark DataFrame

I have in python a Spark DataFrame with nested columns, and I have the path a.b.c, and want to check if there is a nested column after c called d, so if a.b.c.d exists.Simply checking...

View Article



What is the documented behaviour (if any) when someone imports `pkg.__init__[...

To be clear, I'm not suggesting anyone actually should import pkg.__init__ directly. This is to understand potential pitfalls if someone decides to convert a module-only distribution into a package,...

View Article


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>