673 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
-1
votes
1
answer
45
views
How can I access the ${orderId} and ${payment} which is present in the method chaining of the promise to my last block of promise? [duplicate]
const cart = ["shoes","shirts","boxers","pants"]
function creatOrder(cart){
return new Promise((resolve,reject)=>{
if(!ValidateCart(cart)){
...
0
votes
0
answers
20
views
Is there a good way to add columns calculated using a window partition within pandas chaining
My background is in SQL and I was wondering what was the most efficient/readable way of creating multiple columns using the same window partition within a pandas chain.
Suppose I have the following ...
2
votes
2
answers
109
views
Is it possible to create groups/layers in method chaining in Python?
I am aware that I can use method chaining by simply having methods return self, e.g.
object.routine1().routine2().routine3()
But is it possible to organize methods into layers or groups when applying ...
0
votes
0
answers
48
views
How to track access to class variables in a custom ORM using Python descriptors?
I'm building my own ORM in Python and ran into an issue. I want to track the access to class variables in order to know which ForeignKey is being used in each part of my code.
class IQuery(ABC):
&...
0
votes
2
answers
194
views
How to chain operations in pandas entirely in-line?
I often want to both manipulate and display a dataframe during a sequence of chained operations, for which I would use*:
df = (
df
#Modify the dataframe:
.assign(new_column=...)
#View result ...
2
votes
0
answers
68
views
Filter series in method chain
What is the preferred syntax to filter a polars Series without referencing the Series explicitly? I.e. something that works with method chaining. I thought pipe would be an option but it is not ...
1
vote
0
answers
110
views
VSCode: Incorrect indentation after method chaining?
After I've concluded a block with method chaining, VSCode keeps the indentation until I format on save.
Example:
$orders = Order::paid()
->notShipped()
->get();
dd($orders); // <-...
0
votes
1
answer
52
views
Is there a short syntax in javascript for a call chain containing synchronous and asynchronous methods of the same class?
I know of 2 ways that are not very convenient and look inelegant:
Via then:
(new TestClass).syncMethod().asyncMethod().then(self => self.anotherSyncMethod())
Via await:
(await (new TestClass)....
1
vote
4
answers
227
views
C# fluent pattern for nested if conditions
I am working in C#. And I have a scenario as shown here:
var response1 = service.AddSchool(object model, string a);
if (response1.StatusCode == HttpStatusCode.OK)
{
var response2 = service....
0
votes
1
answer
59
views
Optimizing Memory and Performance for Immutable Chain Method Classes Handling Large NumPy Arrays
I'm working on a Python project that involves processing large numpy arrays using a chain of transformations. I've implemented two classes: Sample for individual arrays and SampleCollection for ...
3
votes
2
answers
295
views
How do I compose or chain multiple function in Python
When writing a program, I often want to perform a series of steps on a piece of data (usually a list or string). For example I might want to call a function which returns a string, convert it to a ...
1
vote
4
answers
132
views
Can't I insert an element at the start of array with a chained method without using map?
I have a chain of methods that treat an array. Then I was trying to do a simple thing: add an element at the start of the array in a method chain. Initially I tried:
console.log(
[1, 2, 3]
...
1
vote
1
answer
419
views
Alternative to df.rename(columns=str.replace(" ", "_"))
I noticed that it's possible to use df.rename(columns=str.lower), but not df.rename(columns=str.replace(" ", "_")).
Is this because it is allowed to use the variable which stores ...
1
vote
2
answers
280
views
Fluent interfaces with pipelining or method chaining in Python
I am coming to Python from F# and Elixir, and I am struggling heavily in terms of cleanly coding data transformations. Every language I have ever used has had a concept of a pipeline operator and/or ...
2
votes
5
answers
85
views
How to Select First N Key-ordered Values of column within a grouping variable in Pandas DataFrame
I have a dataset:
import pandas as pd
data = [
('A', 'X'),
('A', 'X'),
('A', 'Y'),
('A', 'Z'),
('B', 1),
('B', 1),
('B', 2),
('B', 2),
('B', 3),
('B', 3),
(...