All Questions
1,285 questions
1
vote
1
answer
56
views
Finding Numerical Relationships between Columns
I have selected a subset of numerical columns from a database and I want to iterate through the columns selecting a target_column and comparing it with the result of a numerical operation between two ...
1
vote
1
answer
38
views
Optimize Persistence Analysis with Rolling Windows in Pandas, Handling Overlaps Between Months
I’m relatively new to Python and coding in general. I’m working on a project to perform persistence analysis in a large dataset and am trying to avoid using for loops for efficiency. I’d appreciate ...
0
votes
2
answers
52
views
How to populate columns only where they match row value in another set of columns?
I'm trying to iterate through a subset of a dataframe and see if the value in the row matches a column heading in the main df. In the examples below I've reduced the number of columns but in the real ...
2
votes
2
answers
197
views
Iterating over each dataframe in a list of dataframes and changing name of first column
I'm trying to iterate through a list of datraframes and do two things, replace blanks with "_" (which I've done) and add a suffix to the first column of each dataframe. I know I can access ...
-1
votes
1
answer
51
views
Loop a number in the name of the DF and filtering
I want to create a loop from 1 to 8 to replace the #7 in each DF name and filtering of this code. How can I do this?
So far, my code is as follows:
df_sample_7 = df[df["quality"]==7]
...
0
votes
0
answers
66
views
How to get every combination possible in a for aggregatation
I'm trying to get every combination possible using a list of columns so that I can perform an aggregate function based on column i which is not in the columns list.
I was able to use the code below to ...
1
vote
1
answer
57
views
What tool should I use to create new column in dataframe based on multiple condition
I have column (Column1) in dataframe that contain information about work centers and values that I need to assign names of these work centers in empty column (Column2), example:
Input:
Column1:
...
1
vote
2
answers
369
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
2
answers
40
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 ...
1
vote
3
answers
67
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 ...
0
votes
0
answers
34
views
Is there any option to return column/row value in pandas instead of printing [duplicate]
Hi, Above is my data frame I want to execute .csh launch for given machine, is there any way to iterate and execute .csh instead of printing value using iterrows.
for idx, row in df.iterrows():
...
1
vote
1
answer
48
views
How to create dataframe column that references a list of lists and assigns a value
It seems my question is similar to a few others but I can't find one that fits my exact question, so apologies if I did not come across this particular answer if it already exists. This question was ...
0
votes
1
answer
62
views
Loop first column over multiple columns and print into rows [duplicate]
I have a CSV file that has multiple columns (screenshot attached). The first column has the identifier and the remaining columns have names of individuals. I would like to loop the first column over ...
1
vote
1
answer
99
views
Using loops to find multiple values in a single column of a data frame
I am fairly new to python and am working with a dataframe with millions of rows. I have a time series with fluctuating values and need to identify the rows with certain values. Specifically, I am ...
1
vote
1
answer
67
views
loop multiple row data to a single row in dataframe [duplicate]
I am extracting data points from a multi line text file and and trying to add the group data to a single row in the dataframe, but I am getting each data point on its own row I would like to flatten ...