All Questions
2,713
questions
0
votes
0
answers
13
views
Normalizing Dataframe with a json column
Hi i am looking for a efficient way to normalise a data frame that contains a column with json data.
i get json response from a website that is saved as a dataframe.
The structure is shown below
enter ...
1
vote
2
answers
94
views
How to calculate the Relative Strength Index (RSI) through record iterations in pandas dataframe
I have created a pandas dataframe as follows:
import pandas as pd
import numpy as np
ds = { 'trend' : [1,1,1,1,2,2,3,3,3,3,3,3,4,4,4,4,4], 'price' : [23,43,56,21,43,55,54,32,9,12,11,12,23,3,2,1,1]...
-1
votes
1
answer
71
views
When looping though a dataframe looking for string values. How do I print out rows without duplicating if the search term is found multiple times? [duplicate]
I am importing pandas and reading a csv file.
import pandas as pd
df = pd.read_csv(r'C:\Users\Me\MyFile.csv')
I am converting the dataframe to strings and making the contents lowercase
df_low = df....
2
votes
4
answers
59
views
modify/create column based on groups defined externally
I have a predefined list containing a list of items as below:
group_1<-c("A","B","C")
group_2<-c("D","E","F")
item<-c("A"...
0
votes
2
answers
47
views
Adding a counter for the position of a record in a R dataframe in a "for" loop
I have some code that runs a sports league table standings simulation, using a "for" loop in R. For each iteration of the loop, a table of standings (i.e. a dataframe) df is produced like ...
1
vote
1
answer
59
views
How can I use 2 for loops together (one for each year and one for each day)?
I think I calculated correctly the average distance between three consecutive values when the condition (described in the code) is met. However, I did this calculation only for a single year and I don'...
0
votes
2
answers
30
views
How to get a value from a column from a dataframe if the id is present in multiple columns in another dataframe?
I have 2 dataframes, df1 which are ID numbers of participants (some have more than one ID but is the same person)
df1 <-data.frame(hospid_1=c("A", "B", "C"),
...
2
votes
2
answers
74
views
Generating a column of probabilities in r for a dataframe
I have a dataframe dfof football matches and corresponding mean scoring rates for each team. The first 2 columns are Home and Away teams, the 3rd and 4th columns are mean scoring rates for Home and ...
-1
votes
2
answers
34
views
how to create sub dataframes, appending rows if some column value is included in a list? [duplicate]
I have a dataframe like this
Data = pd.read_csv('info_com.csv')
df1 = pd.DataFrame(Data)
This DF has a column 'Code', that includes all product codes, and the DF pretty much includes all the ...
0
votes
1
answer
55
views
Color code values conditionally in xlsx produced by openxlsx package in R in a loop
My reproducible code below writes a super small .xlsx file that has two sheets.
I was wondering if there might be a way to color-code values of 3 in red, 4 in orange, and 5 in green anywhere in the ...
0
votes
0
answers
19
views
Need help in JupyterLab Python - Reading Excel and Passing variables
I'm looking to read excel file (referrals.xls) in batch mode. Goal is to read each row and send a text message welcoming them, and passing their name and the facility where the can live.
Using data ...
1
vote
3
answers
56
views
Concatenating row, column indexes from a dataframe
I have one dataframe like this with the first column is the index (i.e., index = [1,2,3]):
1 2 3
1 0 0.43 0.61
2 0.88 0 0.12
3 0.33 0.95 0
The new dataframe ...
1
vote
1
answer
33
views
How to save time series in a dataframe created in an in r loop?
I have a daily rainfall time series in several rain gauges (in columns) and I am calculating some annual indices, such as precipitation amount on year (PRCPTOT). I used looping to generate the series ...
1
vote
3
answers
52
views
Subset by value in columnA and get the value in a columnC that corresponds to the maximum value row of columnB in R? Automate this using loop
The title is rather confusing (apologies), but I will try to explain it here.
I have a dataset with multiple names of individuals, the number of coffees they have had on a particular day of the week, ...
0
votes
0
answers
11
views
Convert text to dataframe following a pattern in python
I have a list of comments with the next structure and I need to convert them into a dataframe
comments_text = ['The SSS XXX 3\n',
'from NNNNN xxx – 20 abr. 2024\n',
'aaaa! CC DASASD ssss, ddd ,...