string

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

Python: Extract integers from string based on position of specific letters

Python: Extract integers from string based on position of specific letters Question: New to Python Scenario A string is a combination of letters and digits. There is always an integer following a letter. But the number of digits of an integer varies. For letter "A", there is a pattern to locate its position. For example, …

Total answers: 1

Using is statement for strings

Using is statement for strings Question: Can someone explain why I am getting following outputs? (I know this code has SyntaxWarning.) >>> a = ‘book’ >>> a is ‘book’ True >>> a = ‘two book’ >>> a is ‘two book’ False I was expecting same result for both code snippet. Asked By: m.r || Source …

Total answers: 1

Python says string is not in list even though it is

Python says string is not in list even though it is Question: I’m attempting to recreate Wordle as an exercise and need to get a guess from the user and then compare it to a list of valid words. Even when I input a string that is in the list, it’s treated as if it …

Total answers: 2

Finding and replacing symbols in list elements

Finding and replacing symbols in list elements Question: I need to take a list of items (that list is not static and will change every time the script is run) that may or may not have multiple certain symbols in the list elements, for example: a = [‘C:\Temp\Folder1’, ‘C:\Temp\Folder2’, ‘C:\Temp\Folder3’, ‘C:\Temp\Folder4’, ‘%ALLUSERSPROFILE%\Temp’, ‘%WINDIR%\Temp’] and I …

Total answers: 1

Python joining strings fails

Python joining strings fails Question: I have an odd problem with my code and cannot find the mistake. I am trying the reverse names in "SURNAME, First Names, Religious Title" format to "First Names Surname" and have written the following lines of code: try: for x in range(0, df_length): print(df_length – x) e_df=df.iloc[[x]].fillna("@") # virtual …

Total answers: 1

How to create a column as a list of similar strings onto a new column?

How to create a column as a list of similar strings onto a new column? Question: I’ve been trying to get a new row in a pandas dataframe which encapsullates as a list all the similar strings into it’s original matching row. This is the original pandas dataframe: import pandas as pd d = {‘product_name’: …

Total answers: 1

ctypes character pointers with same byte string points same location

ctypes character pointers with same byte string points same location Question: I am creating two ctypes character pointers with same byte string via: import ctypes as ct var1 = ct.c_char_p(b’.’*80) var2 = ct.c_char_p(b’.’*80) # how I check the values: api = ct.CDLL(‘api.dll’) api.function1(var1, var2) # values of the vars are changed after running the above …

Total answers: 2