Category : string

I have a pandas dataframe like this: A B C D E 0 aaa 5.56000000 0.01000000 1.00000000 0.00001000 1 bbb 0.49000000 0.00100000 0.01000000 0.00010000 2 ccc 1.70000000 0.10000000 0.10000000 0.00100000 3 ddd 5.35000000 0.00001000 0.00001000 0.01000000 4 eee 6.00000000 16.00000000 0.00000100 1.00000000 I need remove trailing zeros and at the same time, round values after ..

Read more

I recieve a payload like this (with more items of course): [{‘symbol’: ‘ETHBTC’, ‘bidPrice’: ‘0.07729000’, ‘bidQty’: ‘5.03500000’, ‘askPrice’: ‘0.07729800’, ‘askQty’: ‘0.09520000’}, {‘symbol’: ‘LTCBTC’, ‘bidPrice’: ‘0.00337600’, ‘bidQty’: ‘91.41500000’, ‘askPrice’: ‘0.00337700’, ‘askQty’: ‘30.81900000’}] and I need just extract the value for the key: bidPrice for a specific symbol I try this: (?<=ETHBTC.)(.+?), and obtain this: , ‘bidPrice’: ..

Read more

I have an array of numbers in python. I saved it using the code below file = open("A.txt", "w+") for i in range(300): content = str(A[i]) file.write(content) file.close() But when I wanted to read it with this code def readFile(A): fileObj = open(‘A.txt’, "r") #opens the file in read mode words = fileObj.read().splitlines() #puts the ..

Read more

I want to create new methods for str datatype. Here’s what I tried class str(str): def __init__(self) -> None: super().__init__() def work(self): # Just for testing print("works") Here, when I initialize strings using str() this works but wrapping them around simple quotation this raises the error AttributeError: ‘str’ object has no attribute ‘work’ Like this: ..

Read more