Posts by Jessica Voigt • 883 points
29 posts
-
3
votes2
answers56
viewsQ: Apply a function to a dataframe R
I created a function to automatically check if the value of a column is contained in a list. I could do dplyr::mutate + dplyr::ifelse, but as they are for many columns, it would be a very long code.…
-
3
votes3
answers69
viewsQ: Matplotlib sorting using index as bar denominator
I am at an impasse and cannot find a solution. I wish to generate a Bar Plot from a dataframe that is reordered in descending order. I would like the bar name to be the index (0 to 5) When I plot my…
-
0
votes1
answer42
viewsQ: Python Beautifulsoup remove tag within tag
I’m having a problem while making a Scrap of a page and capturing text. Basically the beginning of my code is as follows: url0 =…
-
2
votes1
answer63
viewsQ: Regex Python Remove everything before the first letter in a string
Another question from REGEX that none of the answers I found follows. I have a dataframe that some strings start erroneously with things that are not Letters, for example : t = ['. Subordinam-se ao…
-
3
votes1
answer39
viewsQ: regex python delete all after the second occurrence of a whitespace
That should be very simple and I can’t find an answer. I have several strings of different sizes that have more or less the same pattern: 'Art. 1° E' 'Art. 15. As' What I want to do is delete…
-
3
votes2
answers301
viewsA: python np.Where with two conditions
I got. x['D'] = np.where((x.A > 0) | (x.B > 0), True, False)
-
3
votes2
answers301
viewsQ: python np.Where with two conditions
Hello, I have the following dataframe: import pandas as pd import numpy as np x = pd.DataFrame({'A': [1,2,3,0], 'B': [5,0,0,1]}) What I want is to create a column’D', which is True if the two…
-
1
votes0
answers49
viewsQ: How to import a huge CSV into Python?
Hello, I’m working on a enrollment file for the School Census. I want to import in Python but none of the answers I’m looking at are working. pandas pd.read_csv() takes a long time and cannot open.…
pythonasked Jessica Voigt 883 -
2
votes2
answers343
viewsQ: Getting maximum value of each grouping with groupby pandas
Hello, i have the DF below which I would like to group by 'country' and get the maximum population value: df = pd.DataFrame({'pais': ['Brasil', 'Brasil' , 'EUA', 'EUA'], 'cidade': ['Santos', 'São…
-
4
votes1
answer139
viewsQ: Perform mutate in columns simultaneously
Hello, I have a dataframe where I want to apply the same function in several columns at the same time. I tried to use the dplyr::mutate_at but I don’t think I understand the logic of this operation.…
-
1
votes1
answer385
viewsQ: How do version control ( git, version control) using notebook jupyter?
I recently started programs in Python using the Jupyter Notebook (web) and wanted to give a push in my Github repository. I cloned my repository through cmd, I changed the document, I did a lot of…
-
2
votes2
answers169
viewsQ: Remove all after the second occurrence of a comma
I have a df with addresses and want to remove everything that is after the second comma. exemplo <- c("Rua Pajé, 30, apto 44", "Av. Brasil,55, blocoB") What I’ve already tried:…
-
2
votes2
answers213
viewsQ: Reorder bars in ggplot2 according to one of the fill variables (Fill)
Hello, I have a graph that shows the proportion of equipment available in schools of Pernambuco, and I would like to order it from the equipment with greater presence (greater has) to those with…
-
3
votes1
answer209
viewsA: Remove all before the first occurrence of a word gsub regex
I asked in stackoverflow in English and got the answer: To keep the "what" sub(".*?(que)", "\\1", x) and not to keep the "what" sub(".*?que", "", x)
ranswered Jessica Voigt 883 -
4
votes1
answer209
viewsQ: Remove all before the first occurrence of a word gsub regex
This is so simple but I can’t find the answer! I would like to delete everything before the first occurrence of the word "that" in a string: What am I doing: v <- c("blabla que 1", "blabla que eu…
rasked Jessica Voigt 883 -
4
votes1
answer50
viewsQ: Join scattered values on different lines in the same line
Hello, I have a database in which I used tidyr::spread which resulted in information spread across several lines. I would like to join the different lines in one. Example: df <- data.frame(obs =…
rasked Jessica Voigt 883 -
2
votes0
answers122
viewsQ: Extract in R tables that take up more than one page in pdf files
Hello, Have a pdf containing a table and I want to extract this table to be able to analyze in R. I am using the tabulizer::extract_tables() . As the table occupies more than one page, it returns me…
rasked Jessica Voigt 883 -
4
votes1
answer82
viewsA: Select the dataframe with the highest number of rows in a R-list
I have managed to find an answer that is not ideal but serves my purposes. #contando o número de linhas de cada dfs: cnt <- sapply(lista, nrow) # Agora atribuindo a um DF final: df_final <-…
ranswered Jessica Voigt 883 -
5
votes1
answer82
viewsQ: Select the dataframe with the highest number of rows in a R-list
Hello, I am drawing a loop and at a certain precise moment select the dataframe with the highest number of lines within a list. Example: df1 <- data.frame(a = 1:15) df2 <- data.frame(b = 1:35)…
rasked Jessica Voigt 883 -
2
votes1
answer276
viewsQ: Download from automatic download link and save changing directory in R
I have a list of links that automatically download pdf files and would like to save them with a new name in a folder that I created with dir.create(). I thought of originally importing the file as…
-
0
votes2
answers50
viewsA: Rmysql - My querys return a list
I managed to solve my problem! library(RMySQL) library(dbplyr) conexao <- dbConnect(RMySQL::MySQL(), dbname = "name", host = "localhost", port = 3306, user = "user", password = "my password") #…
-
0
votes2
answers50
viewsQ: Rmysql - My querys return a list
Hi, I’m working with a database that I usually access with Workbench. To start importing directly into R, I am using the Rmysql library. I can make the connection and find my tables, but when it…
-
2
votes1
answer80
viewsQ: Filter lines without knowing the column name in R
Hello, how can I select a row from a data frame that contains an expression but I don’t know which column that expression will be in?
rasked Jessica Voigt 883 -
9
votes3
answers166
viewsQ: Find an expression in several elements of a list
Guys, I got a problem. I have 200 spreadsheets with some data from a survey, and I am importing into R and, because they are with different columns, I assign to each element of my list a different…
rasked Jessica Voigt 883 -
1
votes2
answers146
viewsQ: Find a number after a specific word with grepl and regex {r}
Hello, I have a list of addresses and I’m trying to verify which ones have numbers and which don’t. However, I have some strings that end with number and I’m trying to create a regex to filter these…
-
2
votes2
answers737
viewsQ: How to replace a space by semicolon between two words with gsub()
I have a problem to solve and I can’t write the correct regex. I want to add the semicolon between two emails: ex <- "[email protected] [email protected]" #resultado esperado: [1]…
-
2
votes1
answer1242
viewsQ: Removing regulartable decimal places() flextable package {R}
I am making a report in . rmd to export to . docx and to mount the tables I am using the package "flextable" , which works for this type of export. The problem is that when I go to assemble the…
-
2
votes1
answer231
viewsQ: Alternative to Miktex
Hello. I am making a document in RMD in Rstudio and would like to export it to word or pdf. I saw that for this I need to install Miktex. However, even following all the steps ( the most brief…
-
3
votes1
answer109
viewsQ: Copying files with the same name to a directory without overwriting (R!)
Hello, I have a problem. I have a dummy directory that contains a set of folders, each folder within itself contains a protocol folder, and within each folder I have one or more files. Ex: Pasta…
rasked Jessica Voigt 883