All Questions
2,354
questions
0
votes
0
answers
42
views
Speed up for loop to merge two dataframes in pandas
This is my code:
import time
st = time.time()
# Determine the smaller DataFrame
if len(purp_expanded) <= len(demog_expanded):
smaller_df = purp_expanded
larger_df = demog_expanded
...
1
vote
0
answers
78
views
Optimize loops in Numpy correlation matrices
I have a piece of code to calculate price sensitivity based on the product and its rating.
Below is the original data set with product type, reported year, customer’s rating, price per unit, and ...
0
votes
2
answers
70
views
How to count number of rows in a data frame filtered with complete.case function?
I am working on an assignment to find the title. But I can't get the result to match exactly what the assignment requires. The iteration does count the observation in both columns, "sulfate" ...
-1
votes
1
answer
40
views
How can I select a value from one dataframe based on two other values in another dataframe
From the following two dataframes, I want to substitute all data$code columns with the corresponding code$atc_code. To do this, the data$name value should correspond with code$med_name, and the data$...
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
3
answers
54
views
Looping through 2 columns and all rows in R and forming 2 new column based on their values
I've got an R Dataframe df with two columns Country1 and Country2 and a certain number of rows. I also have two vectors Continent_Europe and Continent_Africa. Every element of Country1 and Country2 ...
0
votes
1
answer
19
views
How do I fill missing values in a dataframe with the values found in another dataframe using a lookup value? [duplicate]
Basically, I have a df with car model+year as a string in 1 column. The dataframe is a collection of used cars for sale so there are duplicate model+year rows but not duplicated entire rows. In this ...
1
vote
2
answers
35
views
Create dataframes with parametrized names [duplicate]
I have a dataframe like:
df
name value
0 a 10
1 a 5
2 b 4
3 b 8
I want to create filtered datasets using the 'name' feature. Something like:
for i in ['a', 'b']:
df_{i} = ...
0
votes
0
answers
33
views
Transfering information between dataframe rows
I have a Dataframe in the form of a genealogy tree with the following columns - ("Generation", "Child_name", "child_hair_color", "Parent_name", "...
-1
votes
2
answers
44
views
Loop and store muliple paths Pandas
Goal: Parameterize multiple paths and merge all data on ID using pandas. For example, I have multiple paths below:
\Users\Documents\202301\data01.pqt
\Users\Documents\202302\data02.pqt
\Users\...
0
votes
1
answer
31
views
Ordereddict - How to iterate to read the same cell in all of the sheets within an Excel file?
In the context of ordereddict, I'd like to loop through all of the sheets in my Excel file, read the content of the B2 cell from each sheet, and print it out. Later, I plan to set conditions based on ...
0
votes
1
answer
69
views
How to left blank/fill up a column with zeros depending on a string value of a cell?
I am manipulating an excel file with three different sheets:
Ideally, the Dummy column has to be filled up with zeros by default, except for when the student's name is either 'Roberto' or 'Leonardo', ...
0
votes
2
answers
59
views
Comparing data from two dataframes and filtering them
I've recently worked on a project in which I use pandas dataframes to store data. I've currently got two dataframes containing odds from sportsbookies for football games, with this data I want to ...
1
vote
1
answer
26
views
Resolving multiple Python data frames within single object
I'm attempting to loop through multiple pages (2 for the purposes of this example) of a website, scrape relevant customer reviews data, and ultimately combine into a single data frame.
The challenge I'...
1
vote
1
answer
123
views
How to iteratively create matrices/vectors from columns/unique row values of dataframe, and pass them to subsequent code?
I want to iterate a chunk of code across columns in a dataframe, to create a results matrix. I am getting stuck with how to iteratively create new objects and matrices using/named after values in a ...