type-conversion

How do i convert string percentage into float

How do i convert string percentage into float Question: I am using a tkinter GUI with the yt-dlp library, when approaching to make a progress bar, I get a problem to conversing the str hook into a float I have this string "x1b[0;94m 0.0%x1b[0m" that I need to turn in to a float into this: …

Total answers: 3

How to format different data types to a dd/mm/yyyy format in Python

How to format different data types to a dd/mm/yyyy format in Python Question: I have an code that I want to change all the date column to a format of dd/mm/yyyy. All the values passed in the date column are already in this kind of format, even the second value: 01/02/2001, where I want to …

Total answers: 1

Leading zeros in an int column gets removed when converted to string – python

Leading zeros in an int column gets removed when converted to string – python Question: The title here basically explains my issue/ask, I have an int column with more than 12 digits that starts with leading zeros. my problem is that when i convert these values to string some values lose their leading zeros which are …

Total answers: 1

I have a timestamp and I want to add 100 miliseconds to it

I have a timestamp and I want to add 100 miliseconds to it Question: this is a python / pandas data type question. So lets say I have a timestamp, which is in STRING format: 1675242910384942479 I would like to know the timestamp + 100 milliseconds. Ideally I would like a function take takes in …

Total answers: 1

polars native way to convert unix timestamp to date

polars native way to convert unix timestamp to date Question: I’m working with some data frames that contain Unix epochs in ms, and would like to display the entire timestamp series as a date. Unfortunately, the docs did not help me find a polars native way to do this, and I’m reaching out here. Solutions …

Total answers: 2

Create new variables that are equal but in a different type

Create new variables that are equal but in a different type Question: Some of the variables in my df are in object dtype and I want to change them to int, and create a new variable to add to the df. This is what I tried " df_l[‘price2’] = df_l[‘price’].astype(‘int’) df[‘host_acceptance_rate2’] = df_l[‘host_acceptance_rate’].astype(‘int’) df_l[‘host_is_superhost2’] = …

Total answers: 1

Type conversion of custom class to float

Type conversion of custom class to float Question: I have a class customInt, which looks something like this: class customInt: def __init__(self, value): self.value=int(value) def __add__(self, other): return foo(self.value+other.value) # do some other stuff obj=foo(1.23) Is it possible to create an operator/attribute/property/… to cast the object obj to a float, so that it’s possible to …

Total answers: 1

Error while converting String elements of List of Lists to float

Error while converting String elements of List of Lists to float Question: This is in reference to my previous question related to extracting data from .asc file and separating them while having multiple delimiters. I want to perform mathematical operations on the float elements of the list of lists generated from the above question. The …

Total answers: 2

Extract int from objects in column that has multiple metrics that need scaling

Extract int from objects in column that has multiple metrics that need scaling Question: My column has over 9000 rows of Mb and Kb objects appearing as numbers, that need to be converted all into Kb values (by multiplying Mb values to 1000). This is a snippet of the column values: array([‘5.3M’, ’47M’, ‘556k’, ‘526k’, …

Total answers: 1