0

Python Help: Hi I'm stuck on my code, I need to be able to grab the dates and Select data for the 30-year period (January 1988 to December 2018). and to Store the selection in a new variable 'selection'

import pandas as pd
import pandas_datareader as pdr
import matplotlib.pyplot as plt
from datetime import date


df = pd.read_csv('helsinki-vantaa.csv.csv', parse_dates=['DATE'], 
index_col=['DATE'])

df.index
df.head()

#print(len(data))

rows_count = len(df.index)
rows_count = len(df.axes[0])
rows_count = df.shape[0]
rows_count = df.count()[0]

print(df)
BeRT2me
  • 12,699
  • 2
  • 13
  • 31
  • 1
    Please don't post images of code, data, or Tracebacks. Copy and paste it as text then format it as code (select it and type `ctrl-k`) … [Why should I not upload images of code/data/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question) … [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – wwii Jul 07 '22 at 02:09

1 Answers1

0
selection = df[df.index.to_series().between('1988-01-01', '2018-12-31')]
BeRT2me
  • 12,699
  • 2
  • 13
  • 31