converters

Reading csv with numpy has extra row of 1's

Reading csv with numpy has extra row of 1's Question: I am using np.genfromtxt to read a csv file, and trying to use the converters argument to preprocess each column. CSV: "","Col1","Col2","Col3" "1","Cell.1",NA,1 "2","Cell.2",NA,NA "3","Cell.3",1,NA "4","Cell.4",NA,NA "5","Cell.5",NA,NA "6","Cell.6",1,NA Code: import numpy as np filename = ‘b.csv’ h = ("", "Col1", "Col2", "Col3") def col1_converter(v): print(f’col1_converter …

Total answers: 1

convert list with keys & values to json format( python)

convert list with keys & values to json format( python) Question: code i am using show_config = self.show_task(ha_task) show_config = show_ha_config["tasks"][0]["task-details"][0][ "output" ] # need to decode into base64 show_decoded = base64.b64decode( bytes(show_config, "utf-8") ).decode("ascii") show_conf = show_decoded.split("n") return show_conf return show_conf = [ ”, ‘VSID: 0 ‘, ‘VRID: 0 ‘, ‘Type: VSX Gateway’, ‘Name: …

Total answers: 1

ModuleNotFoundError: No module named 'forex_python'

ModuleNotFoundError: No module named 'forex_python' Question: As I was trying to practice building a Currency Converter python program, guided by one of the open resources, I installed forex-python and ensured it was installed: $ pip freeze certifi==2022.12.7 charset-normalizer==2.1.1 colorgram.py==1.2.0 forex-python==1.8 idna==3.4 Pillow==9.4.0 prettytable==3.5.0 prettyTables==1.1.5 requests==2.28.1 simplejson==3.18.1 urllib3==1.26.13 wcwidth==0.2.5 Then the code was copied/pasted without further …

Total answers: 1

Convert CSV to JSON using python pandas

Convert CSV to JSON using python pandas Question: I have an CSV file of having data I want to convert into JSON format but I get issue about the formation. Data input in csv file: Full CSV: rarities.csv I have tried this code but it doesn’t get the desired result. Here is the code : …

Total answers: 1

how to make binary to bit 8 in python

how to make binary to bit 8 in python Question: i have variable contains with binary with type int ([101, 1101, 11001]) but i want to xor it with another variable, so i must change to string and add "0" so it has 8 number example 101 it’ll become 00000101 i was trying change int …

Total answers: 2

sum up a numeric string (1111 = 1+1+1+1=4)

sum up a numeric string (1111 = 1+1+1+1=4) Question: #Develop a program that reads a four-digit integer from the user and displays the sum of the digits in the number. For example, if the user enters 3141 then your program should display 3+1+4+1=9. ri = input("please enter four digits") if len(ri) == 4 and ri.isnumeric() …

Total answers: 5

Convert png/jpg to word file using python

Convert png/jpg to word file using python Question: I need to convert lots of jpg/png files to docx files & then to pdf. My sole concern is to write the data in an image to a pdf file & if I need to edit any text manually, I can do that in word & save …

Total answers: 2

Base32 character conversion to a 5bit value, Python to Java

Base32 character conversion to a 5bit value, Python to Java Question: I have some Python code where each given Base32 character is converted to a 5bit value. I need to rewrite it in Java, but I don’t know the Java equivalent/syntax for this format function. word_safe_alphabet = "23456789CFGHJMPQRVWXcfghjmpqrvwx" d = {} i=0 for char in …

Total answers: 1

How to use converter in Pandas when using a MultiIndex

How to use converter in Pandas when using a MultiIndex Question: The issue I have an excel table where the first row is a header and the second row is the unit of measurement for the rest of that column (i.e. nanometers, microns). Pandas provides an excellent read_excel function where I can pass a dictionary …

Total answers: 2