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)

```
A simple way would be to use a loop, but that's inefficient in terms of time. However, if you don't mind, you can loop through the array

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

```

Basically you set up zero, whenever you find the condition true, you set to 1 and keep one until the condition is met to become -1, and so on. This is slower than the approach you used, but it's the simplest way to "keep the last value" as you are increasing the value and you know which value you had before.