Question: I'm using Nest framework and trying to make a Post request that gets a file and data here's what I did 

```
  @Post('upload')
  @UseInterceptors(FileInterceptor('file'))
  uploadFile(@Body('data') addRefundDto:AddRefundDto,@UploadedFile() file) {
    console.log(addRefundDto);
    console.log(addRefundDto.price);
    console.log(addRefundDto.refundType);
    return '   ';
  }

```

which prints : 

> 
> {
>  "refundType":"test",
>  "currency":"usd",
>  "price":58.5,
>  "flightId":4,
>  "iAiCard":true
>  }
> 
> 
> undefined
> 
> 
> undefined
> 
> 
> 

It's like the dto gets the json as text (I also tried calling @Body()instead of @Body('data'))

I removed "Content-Type","application/json" from the request in PostMan so I can upload the file, is there anyway to solve this nicely ? 

Thanks a lot !

Answer: 
Although this is already answered, however, the fastest way to compute such result is usually using `np.where` as follows:

```
import pandas as pd
import pandas_datareader as dr
import numpy as np
from datetime import date

df = dr.data.get_data_yahoo('SPY',start='01-01-2019',end=date.today())

df['HC'] = df['Close'].rolling(20).max() 
df['LC'] = df['Close'].rolling(20).min() 

```

There is a nested logic in the following:

1. Create an empty array
2. Replace Values with -1 under condition
3. Replace Values with 1 under condition

```
df['Flag'] = np.where((df.Close == df.HC), 1, 
         np.where(df.Close == df.LC, -1, np.full(df.Close.count(), np.nan)))
df.Flag.fillna(method='ffill', inplace=True)

```

In terms of performance:

```
%%timeit
df['Flag'] = np.where((df.Close == df.HC), 1, 
         np.where(df.Close == df.LC, -1, np.full(df.Close.count(), np.nan)))
df.Flag.fillna(method='ffill', inplace=True)

```

```
912 µs ± 49.2 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

```

This is definitely better that loops or nested if conditions.

For example @Tim Mironov answer:

```
%%timeit
pos_indexes = (df.Close == df.HC)
neg_indexes = (df.Close == df.LC)

df.loc[pos_indexes, 'Good_Flag'] = 1
df.loc[neg_indexes, 'Good_Flag'] = -1

df.fillna(method='ffill', inplace=True)

```

```
4.43 ms ± 92 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

```
You can use more built-in functionality of Pandas, specifically `fillna` method and usage of logical indexing.
I've added a portion of code to your original one to create an additional `Good_Flag`:

```
import pandas_datareader as dr
from datetime import date

df = dr.data.get_data_yahoo('SPY',start='01-01-2019',end=date.today())

df['HC'] = df['Close'].rolling(20).max() 
df['LC'] = df['Close'].rolling(20).min() 

df['Flag'] = [1 if (df.loc[ei, 'Close'] == df.loc[ei, 'HC']) else 
              -1 if (df.loc[ei, 'Close'] == df.loc[ei, 'LC']) else   
              0 for ei in df.index]

pos_indexes = df.Close == df.HC
neg_indexes = df.Close == df.LC
df.loc[pos_indexes, 'Good_Flag'] = 1
df.loc[neg_indexes, 'Good_Flag'] = -1
df = df.fillna(method='ffill')

```

Pay attention that I used the `fillna` method with `ffill` attribute to specify a "Forward Pass".

Edit:
To make thigs clear, the original `Flag` column is left here on purpose and the calculation of the new `Good_Flag` column doesn't rely on `Flag`.

To demonstrate the desirable behaviour:

```
plt.plot(df.Flag, color='blue')
plt.plot(df.Good_Flag, color='red')
plt.legend(['Flag', 'Good_Flag'])
plt.show()

```

[![enter image description here](https://i.stack.imgur.com/t9zuZ.png)](https://i.stack.imgur.com/t9zuZ.png)