Posts by Hugo Salvador • 266 points
12 posts
-
-1
votes2
answers107
viewsA: convert strings to python
I would solve so: with open('Calculadora lendo TXT.txt') as arquivo: for linha in arquivo: print(f'{linha}: {eval(linha)}') Using "with" you do not worry about having to close the file after using…
-
0
votes1
answer28
viewsA: List With Gigantic Array
If there’s only one list inside another and you want to get the list from within, you can use: list = lst[0]
-
1
votes1
answer253
viewsA: How to order a dataset
It’s a strange demand! Theoretically a table with row records should keep the column data for each row. The way you want it, you will treat each column as independent data. But going for solution,…
-
1
votes1
answer103
viewsA: (Pandas) to_scv error in parameter Sep=
Use: df.to_csv('20191122_Consolidados_camara_de_retencao.csv', sep = ';') This one is saved in the same directory as .py. If you want to set another directory, you can use it for example:…
-
1
votes3
answers1422
viewsA: Search for words that contain a certain letter
Function can be used filter to have the same result: lista = text.lower().split() # transforma texto em lista de palavras com letras minusculas f_filtro = lambda x: 'z' in x # Definine a função de…
-
1
votes1
answer63
viewsA: How to use the Timestamp(). dayofweek method on a dataframe?
To set the day of the week you can use: pd.to_datetime(df['ds']).dt.dayofweek If you want to group all dates into one list per day you can use :…
-
0
votes3
answers1598
viewsA: Break lines in a certain Python character space
I commented on the parts I inserted. I thought it better to break the number and not simply by the size of the line to prevent a number from being broken between lines. texto = 'Calculadora de…
pythonanswered Hugo Salvador 266 -
2
votes1
answer175
viewsA: How to select ALL lines that have a value exceeding 3 or -3 in a pandas dataframe?
On the help page of the function informs that the function entries are: DataFrame.any(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs). The parameter the function is taking as value…
-
2
votes4
answers620
viewsA: How to delete files and folders recursively safely with Python?
You can read the current directory files using the.listdir('.') or indicate the directory you want to read. Another way is using glob.glob('*.dat') where the answer would be a list of files, in this…
-
0
votes2
answers339
viewsA: How to save the result of this code in a list?
If the use of the data is for use only in Python you can think about using the library pickle which is standard in Python distributions. import pickle l = [1,2,3,4] with open("test.txt", "wb") as…
-
0
votes1
answer79
viewsA: Python - Data Analysis - Error reading file in xlsx format
The function to be used is "read_excel", because "read_xlsx" does not exist in pandas:…
-
1
votes1
answer45
viewsA: Selecting Python String List Cell
You can use regex: import re files_list = re.findall(r'OR_[^ ]\.nc', parh) # Se precisar só do primeiro arquivo file = files_list[0]