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: 
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)
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.