Posts by Clayton Tosatti • 1,636 points
68 posts
-
1
votes1
answer235
viewsA: How to sort a python dictionary in descending order?
I used the dictionary as follows: dict= {'1': [44, 32, 56, 57, 43, 21, 36, 35, 39, 27, 23, 24, 25, 26, 31, 28, 29, 30, 20, 22, 18, 19, 8, 1, 33, 2, 3, 4, 0, 6, 7, 9, 17, 10, 11, 12, 50, 55, 13, 14,…
-
0
votes1
answer31
viewsA: Import a file that starts with numbers in Python
Interesting problem... You can do it like this: jogo_01 = __import__('01_Jogo') and I believe that this way also works: import 01_Jogo as meu_modulo…
-
3
votes1
answer100
viewsA: Except is not capturing the exception
It turns out that what you’re trying to capture is no exception, because it’s something that’s just not inside any if. The code that could capture this not valid option should be more or less like…
-
1
votes1
answer158
viewsQ: Why use double clasps in Pandas?
Given the following Dataframes: df = pd.DataFrame([[1, 2, 1], [4, 5, 2], [1, 2 , 3]], columns=['coluna1', 'coluna2','id']) df2 = pd.DataFrame([[1, 7, 1], [4, 'a', 2], [1, 'abc', 3]],…
-
0
votes2
answers127
viewsA: Microsoft Power Bi - Filtering in back-end
To do this you will need to complement your URL with the following add-on: ..URL?filter=Table/Field eq 'value' Something more or less like this: Important remarks: Table (Table) and field (Field)…
powerbianswered Clayton Tosatti 1,636 -
1
votes1
answer65
viewsA: Duplicated, how to pass more than one parameter?
You have to change your line of CONCAT Hudson Try it this way: df_aux = pd.concat([dados[['NOME','PIS','CPF']],dados2[['NOME','PIS','CPF']]]) df_aux.loc[df_aux.duplicated()]…
-
0
votes4
answers333
viewsA: Bring only the values of the Python keys
In a very concise way, that would be it: dicfinal = {} disciplina1 = {'Primeiro' : {'nome': 'Python', 'sigla': 'F0D4', 'periodo': 'Noturno', 'nota': '10'}} disciplina1.update({'Segundo' : {'nome':…
pythonanswered Clayton Tosatti 1,636 -
1
votes2
answers658
viewsA: Check if the values of a certain Dataframe column exist in a certain list using np.Where
Just change the way you compare to the list. Put it like this: df['Sulamericano'] = np.where(np.isin(df['Pais'], america_do_sul), 1, 0)
-
1
votes1
answer399
viewsA: Find equal records in two databases(csv)
Come on, I will assume the premise that in both tables there is at least one common field that is always filled, in my example I will say that this field is the NAME So assuming the files are: CSV 1…
-
1
votes1
answer794
viewsA: Replace certain values by media in a pandas Dataframe
The fillna can’t be so flexible as to create a rule like yours, in which case I would use the (iterrows) to go through the dataframe to make the adjustments. Following your example I created the…
-
2
votes2
answers343
viewsA: Getting maximum value of each grouping with groupby pandas
Using another logic to work easy Jessica. Try it here: df = pd.DataFrame({'pais': ['Brasil', 'Brasil' , 'EUA', 'EUA'], 'cidade': ['Santos', 'São Paulo', 'Orlando', 'Nova York'], 'populacao':…
-
1
votes1
answer384
viewsA: Return pixel of a certain color analyzed by Imagegrab
Murilo tries to follow this line: from tkinter import * from PIL import ImageGrab import pyautogui screen = ImageGrab.grab(bbox =(x1, y1, x2, y2)) screen.show() Where x and y, are print position and…
-
1
votes1
answer167
viewsA: How to make the window transparent background in Kivy
Vitor uses this example function: from kivy.config import Config Config.set('graphics', 'position', 'custom') Config.set('graphics', 'fullscreen', 'fake') Config.set('graphics', 'top', '0')…
-
0
votes1
answer80
viewsA: How to use two database columns as a sort criteria for a Query?
Use this instruction in your Order by ...ORDER BY STATUS DESC, CREATED This will sort everything by STATUS (DESC) first, and then by CREATED (ASC)
-
0
votes1
answer193
viewsA: Changing the name of a data set field - Powerbi
The steps are as follows: Goes into Edit Query: Select the table showing the error ( In my case with the name 'Plan 1' ) right click on it and then select Advanced Editor: In the window that opens…
-
1
votes2
answers478
viewsA: Formula to Count Boolean Values Power BI
In my view the problem is that its formula returns blank values for cases where the "SLA" is not expired. Try using an IF to check the return and put some value if the return is 'null' example: SLA…
-
1
votes3
answers98
viewsA: Sort select displaying something at the end after sorting
Simply add the syntax to your query: . . . order by Tabela2.sts, Tabela1.Indice
-
5
votes1
answer1933
viewsQ: Swap String part in all dataframe columns
I have a dataframe in the following template: lista = [] lista.append(['A1','2','A3']) lista.append(['4','A5','6']) lista.append(['A7','8','9']) df = pd.DataFrame(lista, columns=['A', 'B', 'C']) df:…
-
0
votes1
answer1209
viewsA: Difference between multiple dates in the same column
After a few attempts, I asked also in the OS. And I got the following solution that worked very well, and can be found completely here: Difference between Multiple Dates in the same column based on…
-
0
votes1
answer1209
viewsQ: Difference between multiple dates in the same column
I have the following problem.. I have the following table: I want to create a calculated column that tells me the difference of days between two dates of the same code (COD), the difference shall be…
-
2
votes1
answer1301
viewsA: Sort per month in power bi
Gabriel in this case can do the following. Create an auxiliary table of 'TEMPO', in this table should contain your months/years (as they appear in your current table) and another column that can be…
powerbianswered Clayton Tosatti 1,636 -
1
votes1
answer825
viewsQ: Copy part of Dataframe where column is Null or Nan
I have the following doubt. I have the following sample dataframe: import pandas as pd df = pd.DataFrame({'A' : [4,5,13,18], 'B' : [10,np.nan,np.nan,40], 'C' : [np.nan,50,25,np.nan], 'D' :…
-
1
votes3
answers881
viewsA: How to calculate difference of dates that are a previous row with MYSQL?
Wallace the query can be made as follows: SELECT A.id, A.created_at, TIMESTAMPDIFF(SECOND,A.created_at,B.created_at) AS timedifference FROM historico_status_solicitacoes A INNER JOIN…
-
6
votes1
answer396
viewsA: Order by command with Sqlite accent
In this case you can use, one of these two: (SUA QUERY) ORDER BY NOME COLLATE UNICODE (SUA QUERY) ORDER BY NOME COLLATE LOCALIZED Follow the reference of the documentation: Localized Collation -…
-
2
votes2
answers5334
viewsQ: How to check the versions of the modules installed in Python?
I installed two modules in Python via anaconda (Conda install): zipfile36; Mysqldb. Using the anaconda prompt I can get the version of both and all my other modules using the command: conda list But…
-
1
votes2
answers66
viewsA: JOIN with LIMIT in Query
Selecting with Distinct on and then using ORDER you get the expected result. SELECT Distinct on(R.ID) R.TITULAR, R.CHECKIN, R.CHECKOUT, H.NOME FROM RESERVA R JOIN HOSPEDES H ON H.RESERVA = R.ID…
postgresqlanswered Clayton Tosatti 1,636 -
1
votes1
answer43
viewsA: Remove space from a column in Opencart
From what I understand Oce needs to leave everything without spaces Here is an example of an SQL statement to remove these spaces and leave everything together. SELECT REPLACE(sku, ' ', '' ) FROM…
-
7
votes2
answers2508
viewsQ: Difference between commands to stop execution
I found that there are several ways to interrupt an execution. Basically what is the difference between using the commands: break; sys.Exit() ( From the module sys); os. _Exit() ( From the module…
-
1
votes1
answer412
viewsA: mysql select order by starting with today’s date
I fall the way I know for this is using FIND_IN_SET The test structure I created was this: CREATE TABLE `tbl_Local` ( `ID` int(11) NOT NULL, `Local` varchar(45) DEFAULT NULL, `COR` varchar(45)…
-
0
votes4
answers261
viewsA: Sequencia Fibonacci
Try it this way Lucas: def fibonacci( n ) return n if ( 0..1 ).include? n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) ) end puts fibonacci( 10 )…
-
2
votes1
answer329
viewsA: Power BI Data Update
Daniel what’s happening is this. powerBI data/dashboards can be worked in two different formats. The first is the DESKTOP In it you work with the application installed on your PC The second is the…
powerbianswered Clayton Tosatti 1,636 -
1
votes1
answer973
viewsA: Why doesn’t Python use 100% of the processor?
In your case what is happening is the following, you are running your routine on a single thread on a system (CPU) that has 4 logical cores. You will need to rewrite your algorithm to be…
-
2
votes2
answers105
viewsA: Add FK in mysql table
The problem can be solved by changing the table : 'tb_invoice' The field you are using from the table tb_invoice(id_invoice) to link in the table tb_invoice item is not primary key(PK). This will…
-
5
votes2
answers1771
viewsA: Turn columns into rows
Unfortunately Mysql does not have Pivot table functions. In this case we can mount using a UNION ALL It follows a possible and very simple solution: select 'Ida sem Volta' descr, Idasemvolta value…
-
2
votes2
answers58
viewsA: Difference between two dates with time greater than 24 hours?
Only as a response complement I use as follows: SELECT DATEINI, NOW(), CONCAT(TRUNCATE(TIMESTAMPDIFF(MINUTE, DATEINI, NOW())/60,0), ':',TIMESTAMPDIFF(MINUTE, DATEINI, NOW())%60 , ':',…
mysqlanswered Clayton Tosatti 1,636 -
0
votes4
answers6351
viewsA: How do I capture each key typed in python
Victor Voce could start searching on 'KEYBOARD LISTENERS'. An example library used in python for keyboard capture and writing is: Keyboard Link to Library Documentation It would be necessary for you…
-
3
votes2
answers6769
viewsA: Convert pandas data frame to array
Klel, in this case Voce can use the function: 'pandas.DataFrame.values' Follow the example of use: import pandas as pd df = pd.DataFrame({'idade': [ 3, 29], 'peso': [94, 170]}) vetor = df.values To…
-
2
votes1
answer713
viewsA: Find most repeated value
Iuri you could use PIVOT TABLE (dynamic table) in pandas That would be about it: import pandas as pd import numpy as np df = pd.read_excel("SEU ARQUIVO") table =…
-
0
votes1
answer517
viewsA: Install nltk in python 3.6
I advise first of all reinstall the module of NLTK, in recent months there have been several changes that may be interesting for Voce. To uninstall just use the command pip uninstall nltk On the…
nltkanswered Clayton Tosatti 1,636 -
1
votes2
answers2322
viewsA: How to ignore accents in an SQL query?
Just need to set up a Collation using the sqlite3_create_collation and use as follows: SELECT * FROM Curso WHERE Descricao LIKE "Logica%" COLLATE NOACCENTS…
-
1
votes1
answer293
viewsA: How to count how many fields are empty in the mysql table
There are other ways to do it, but I use it as follows: SELECT ((CASE WHEN COLUNA1 IS NULL THEN 1 ELSE 0 END) + (CASE WHEN COLUNA2 IS NULL THEN 1 ELSE 0 END) . . . . + (CASE WHEN COLUNA5 IS NULL…
-
2
votes1
answer899
viewsQ: Convert Days & Time (Hours x Minutes x Seconds) to Time only
I have a Dataframe in which I am making the difference between two different dates to get the difference in Hours and Minutes, for example: data_inicial = '2018-07-03 16:03:00' data_final =…
-
2
votes1
answer162
viewsQ: Change more than one value in the same column with an UPDATE
I have the following doubt.. I have the example table - reply in the following format *------------*--------------* |resposta_id | INT | |pergunta_id | INT | |resposta | VARCHAR(45) |…
-
1
votes2
answers4270
viewsA: Filter lines in pandas by a list
In a very simplified way, Voce can use this: def listaFiltro(dataframe, primeiro, segundo, terceiro): return dataframe[(dataframe['nome']==primeiro) | (dataframe['nome'] == segundo) |…
-
1
votes2
answers116
viewsA: Try and except block
Sergio the problem is that Voce is setting the variables as INT after multiplication, this error means that you are multiplying strings, therefore the problem. try that way:…
-
1
votes1
answer62
viewsA: Error running INTERSECT on Mysql
For example you presented the code below will serve: Select Gerentes.*, Funcionario.* from Funcionario JOIN Gerentes ON (Funcionario.Nome = Gerentes.Nome) Only a caveat. In the image that showed…
mysqlanswered Clayton Tosatti 1,636 -
1
votes1
answer641
viewsA: Mysql Error: Each derived table must have its own alias
Ana, use this query below: Select COUNT(questionario.pergunta_id) total,questionario.*, resposta.* from questionario JOIN resposta on questionario.pergunta_id = resposta.pergunta_id Where…
-
3
votes1
answer806
viewsA: Pandas: Dataframe information comparison
Brito, in this case Voce can use the Pandas function - Merge the code must be: df_join = pd.merge(df_acervo1, df_acervo3, how ='inner', on = ['num']) obs. The parameter of ON above represents the…
-
2
votes2
answers327
viewsA: When to use underlining in web hyperlinks?
Well going back a little in history, we can notice that the use of the links in the most known format was due to some main factors. And in the early 90’s its use was much needed due to the few…
-
1
votes1
answer382
viewsA: Delphi Integrator + Scanner
William the only component I know of Scanner for Delphi is the TWAIN. It had been discontinued but another community made upgrades to XE2. Component link: Link…