type-conversion

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

SQLite Database as type "dict"

SQLite Database as type "dict" Question: I am trying to create a quiz application. I have the module which asks the questions, shows the 4 possible answers in a listbox and then you click a button to fetch the result and check if true. My issue is trying to get the data type pulled from …

Total answers: 1

Convert bytes in string using python

Convert bytes in string using python Question: I have bson file, and i dont know what have inside of the document. I see the data type, and conclude the type of data is bytes. So, for undertsand the content the file, i need to save in readable formart. So, the firt step was convert my …

Total answers: 1