types

Timeseries split datetime data type to seperate date and time columns

Timeseries split datetime data type to seperate date and time columns Question: I am importing a CSV file that contains a nonformatted dataset, the date and time are separated but the data type is an object, and the times’ time zone is incorrect. The timezone of this original dataset is EET which is currently 7-hour …

Total answers: 1

How can I solve this double sub-string and astype problem

How can I solve this double sub-string and astype problem Question: In this case I have a problem with this: Im trying to split a column "UbicaciĆ³n Finalizada" in two, but I have a problem with a "," string, I can’t take it out and that make some problems in the after code because I …

Total answers: 1

Correct way to check against type given by string in Python

Correct way to check against type given by string in Python Question: In short, if I have: str_type = "int" to_check = 1 what is the best way to implement the following check? if isinstance(to_check, str_type): … More detailed: I want to use type information given by one JSON file to check the values of …

Total answers: 1

Check that function return types match the def statements in PR test in python

Check that function return types match the def statements in PR test in python Question: I have a Github Action that runs unit tests on each Pull Request (PR). It effectively runs pytest. Seeing that we leverage the type hints introduced in PEP 484, I’d like a method like this to cause a PR check …

Total answers: 1

Pylance requiring explicit type on conformant list variables

Pylance requiring explicit type on conformant list variables Question: I define a type as a Union of Literal strings Color = Literal[ "red", "green", "blue", "yellow", "orange", "purple" ] I have a function that expects a list of strings conforming to the type. def f(colors: List[Color]): … I instantiate a list of conformant strings and …

Total answers: 1

Why do I get "sqlite3.ProgrammingError: Incorrect number of bindings supplied." even though I used a tuple?

Why do I get "sqlite3.ProgrammingError: Incorrect number of bindings supplied." even though I used a tuple? Question: From my Discord bot I’m getting : sqlite3.ProgrammingError: Incorrect number of bindings supplied. The data in the database is [(‘123’, ‘hello world!’), (‘111’, ‘testing lolz’)] and when I run ‘search’ with ‘123’ as id the bot should reply …

Total answers: 1

Python Check only outputting a string

Python Check only outputting a string Question: num = input("Enter Something:") print(type(num)) for some reason when running this code, or any alternative version even without text (string), it still outputs a string. <class ‘str’> is there any way to check for all types like expected? e.g str and int Asked By: umfhero || Source Answers: …

Total answers: 4

How to use Dict to specify type-hint in Python

How to use Dict to specify type-hint in Python Question: I have a function which will return a dictionary like: from typing import Dict def foo() -> Dict[]: params = { "side": "Buy", "symbol": "BTCUSDT", "order_type": "Market", "time_in_force": "PostOnly", "reduce_only": False, "close_on_trigger": False, } return { "method": "POST", "api": "private/linear/order/create", "body": params } What should …

Total answers: 2

If the Python runtime ignores type hints, why do I get a TypeError?

If the Python runtime ignores type hints, why do I get a TypeError? Question: I already know that: The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc. but why does this code check the types for me? def …

Total answers: 1