Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:52:32+00:00 2026-06-17T05:52:32+00:00

I have lots of missing values when calculating rollng_mean with: import datetime as dt

  • 0

I have lots of missing values when calculating rollng_mean with:

import datetime as dt
import pandas as pd
import pandas.io.data as web

stocklist = ['MSFT', 'BELG.BR']

# read historical prices for last 11 years
def get_px(stock, start):
    return web.get_data_yahoo(stock, start)['Adj Close']

today = dt.date.today()
start = str(dt.date(today.year-11, today.month, today.day))

px = pd.DataFrame({n: get_px(n, start) for n in stocklist})
px.ffill()
sma200 = pd.rolling_mean(px, 200)

got following result:

In [14]: px
Out[14]: 
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 2836 entries, 2002-01-14 00:00:00 to 2013-01-11 00:00:00
Data columns:
BELG.BR    2270  non-null values
MSFT       2769  non-null values
dtypes: float64(2)

In [15]: sma200
Out[15]: 
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 2836 entries, 2002-01-14 00:00:00 to 2013-01-11 00:00:00
Data columns:
BELG.BR    689  non-null values
MSFT       400  non-null values
dtypes: float64(2)

Any idea why most of the sma200 rolling_mean values are missing and how to get the complete list ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:52:33+00:00Added an answer on June 17, 2026 at 5:52 am

    px.ffill() returns a new DataFrame. To modify px itself, use inplace = True.

    px.ffill(inplace = True)
    sma200 = pd.rolling_mean(px, 200)
    print(sma200)
    

    yields

    Data columns:
    BELG.BR    2085  non-null values
    MSFT       2635  non-null values
    dtypes: float64(2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have lots of tables with statistical data (environment related) and wondering if there
Update: My apologies... I should have specified that there are missing values for some
I have a client submitting a web-request (POST) of XML data to a server.
note from N00B land again. I have read lots about sorting arrays - wanted
I have an entity class like this (with lots of stuff missing): class Parent
I have read lots of Autofac docs/wikis which indicate I can get a list
I have lots of details. I want to stack them within an array, can
I have LOTS of logs and I need to compress them in a weekly
I have lots of directories filled with a bunch of TeX documents. So, there's
We have lots of stored procedures which all contain a lot of comments. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.