0

I am a newbi in Python and after upgrading to Mint 20.3 from 18.3 including installing all necessary again I get this Warning: Boolean Series key will be reindexed to match DataFrame index. I did not get the warning in the Pandas version I used in Mint 18.3

The warning is given in these two lines:

File name:Line number:UserWarning: Boolean Series key will be reindexed to match DataFrame index.

MaxDate =analysedata[data['Adj Close'] == Max]['Date']

File name:Line number:UserWarning: Boolean Series key will be reindexed to match DataFrame index.

MinDate =analysedata[data['Adj Close'] == Min]['Date']

I try to get the MinDate and MaxDate for the minimum and maximum value of the "Adj Close" row in the analyze area which is described between "analysestart" and "analyseend"

I think it is doing correct but I do not like to have the warning. Hope someone can give a hint

I did see the other question and answer but it did not help. Is it because my analysedata is shorter than data? I tried to make a new data frame analysedata2 but result is the same. If I use 'Date' instead of just Date I get syntax error.

for ferm in ferms:
    stock = ferm
    stockFile = ferm

    data = pd.read_csv(ferm,  header=0)
    if os.stat(ferm).st_size > 4: 
        print(stockFile)
        data['Date'] = pd.to_datetime(data['Date'])
        data["20d"] = np.round(data["Adj Close"].rolling(window = 20, center = False).mean(), 2)
        data["70d"] = np.round(data["Adj Close"].rolling(window = 70, center = False).mean(), 2) 

        data['plot'] = (data['Date'] > startplot) & (data['Date'] <= end) 
        plotdata=data[data['plot']]
        plotdata
        
        data['analyse'] = (data['Date'] > analysestart) & (data['Date'] <= analyseend) 
        analysedata=data[data['analyse']]
        analysedata2 = analysedata.loc[data['analyse']]
        analysedata2[analysedata2.Date.isnull()]

        analysedata2                       
        
        Max=analysedata2['Adj Close'].max()

        MaxDate =analysedata2[data['Adj Close'] == Max]['Date']
           

        Max2 = float("{0:.1f}".format(Max))
        Min=analysedata2['Adj Close'].min()

        MinDate =analysedata2[data['Adj Close'] == Min]['Date']
Hennng
  • 19
  • 6
  • Welcome back to Stack Overflow. Your operating system is definitely not relevant to this. If you want to understand what changed in your Pandas installation, you should first *figure out what version you have now and what version you had before*, and then *read the documentation*. – Karl Knechtel Feb 12 '22 at 20:35
  • Another thing you can try doing is [copying and pasting the warning into a search engine](https://duckduckgo.com/?q=Boolean+Series+key+will+be+reindexed+to+match+DataFrame) - which gave me the linked duplicate as the first result. For future reference, please read https://meta.stackoverflow.com/questions/261592 and try to take basic steps to solve the problem yourself before asking on Stack Overflow. – Karl Knechtel Feb 12 '22 at 20:36
  • Sorry, but I tried actually first to search for the warning and found the same link. It just did not help me much. Then changed the question and the lines in the question but I did not find any way to "kind of open" it again so that why I made a new. I will try again. – Hennng Feb 14 '22 at 16:00
  • OK the solution was to use the complete data range to find the MaxDate and not only the analysedata range. MaxDate =data[data['Adj Close'] == Max]['Date'] insted of MaxDate =analysedata2[data['Adj Close'] == Max]['Date'] – Hennng Feb 14 '22 at 17:48
  • "It just did not help me much." In the future, if you have already found something on Stack Overflow that didn't help you, then you should proactively: 1) show that you found it; 2) give the link; 3) *explain exactly why* it did not help you. Alternately, you can try using the comments on the existing question to ask for clarification. – Karl Knechtel Feb 14 '22 at 19:28
  • OK, I will do that. I actually found the solution in an other Stack Overflow question/answer. – Hennng Feb 20 '22 at 20:54

0 Answers0