Posts by jfaccioni • 1,283 points
57 posts
-
2
votes4
answers200
viewsA: Find character succeeded by another character using Regex
Here is a solution that does not modify the original JSON structure (in case you want to save it back to a file with the same "face", for example): string = """ { "array": [{ "id": "123",…
-
0
votes2
answers118
viewsA: Why does multiple variable assignment create a list when used with the asterisk operator?
I don’t know how much this resonates your question, but this implementation (list instead of tuple) allows using * syntax even in cases where the size of the sequence is unknown, as in generators:…
-
1
votes2
answers765
viewsA: Read file in previous python folder
On the path of the error message '/root/extrator/app/controllers../statics/downloads/9837509907462335.zip' is apparently missing a directory separator (bar) between 'controllers' and '..' - your…
-
4
votes1
answer1805
viewsA: Remove Automatically Generated Number Column in Dataframe Pandas
By default, DataFrame.to_excel saves the index of your Dataframe to the Excel table. The index of a Dataframe (also by default) is a numerical sequence starting from 0. It is easy to change this…
-
0
votes2
answers71
viewsA: cut DNA nucleotide string
The solution is to iterate over each nucleotide in the DNA sequence, take the nucleotide + the following two and check if this triad is "ATG". If so, we repeat the meso process until we find the…
-
0
votes1
answer36
viewsA: How to single lines a Dataframe Pandas that vary in just a few fields?
Try it with that code: df = pd.read_excel('companies.xlsx') # seu arquivo de input cnpjs = df['cnpj'].unique() aggregator = [] for cnpj in cnpjs: company_df = df.loc[df['cnpj'] == cnpj] for index,…
-
4
votes1
answer249
viewsA: Validation in the constructor - Python
You need to call the validation method within __init__, for example: class Data(): def __init__(self, dia = 1, mes = 1, ano = 1980): self.__dia = dia self.__mes = mes self.__ano = ano if not…