Skip to content
FacebookTwitterLinkedinYouTubeGitHubSubscribeEmailRSS
Close
Beyond Knowledge Innovation

Beyond Knowledge Innovation

Where Data Unveils Possibilities

  • Home
  • AI & ML Insights
  • Machine Learning
    • Supervised Learning
      • Introduction
      • Regression
      • Classification
    • Unsupervised Learning
      • Introduction
      • Clustering
      • Association
      • Dimensionality Reduction
    • Reinforcement Learning
    • Generative AI
  • Knowledge Base
    • Introduction To Python
    • Introduction To Data
    • Introduction to EDA
  • References
HomeKnowledge BasePythonHow to create a smaller dataset for a…
Python

How to create a smaller dataset for a specific month

January 16, 2024January 18, 2024CEO 192 views

Suppose we have a file that contains historical weather temperature between years 1948 to 2024 in which we want to look at how January temperatures have changed over time.

import pandas
# Load a file that contains Los Angeles weather data
data = pandas.read_csv('LosAngelesWeather_1948-2024.csv', parse_dates=['date'])

# Keep only January temperatures
data = data[[d.month == 1 for d in data.date]].copy()
data

        date	precipitation	max_tmp	min_tmp	rain
0	1948-01-01	0.47	51	42	True
1	1948-01-02	0.59	45	36	True
2	1948-01-03	0.42	45	35	True
3	1948-01-04	0.31	45	34	True
4	1948-01-05	0.17	45	32	True
...	...	...	...	...	...
25229	2017-01-27	0.00	54	37	False
25230	2017-01-28	0.00	52	37	False
25231	2017-01-29	0.03	48	37	True
25232	2017-01-30	0.02	45	40	True
25233	2017-01-31	0.00	44	34	False
copy, dataset, python

Post navigation

Previous Post
Previous post: Process of Fitting the models in machine learning
Next Post
Next post: What is NumPy?

You Might Also Like

No image
Delete a folder in Google Colab
June 20, 2024 Comments Off on Delete a folder in Google Colab
No image
CDF plot of Numerical columns
March 12, 2024 Comments Off on CDF plot of Numerical columns
No image
Python warnings module
March 3, 2024 Comments Off on Python warnings module
No image
How-to: give a specific sorting order to…
February 7, 2024 Comments Off on How-to: give a specific sorting order to categorical values
No image
How-to: When missing data is of type…
February 6, 2024 Comments Off on How-to: When missing data is of type categorical
  • Recent
  • Popular
  • Random
  • No image
    7 months ago Low-Rank Factorization
  • No image
    7 months ago Perturbation Test for a Regression Model
  • No image
    7 months ago Calibration Curve for Classification Models
  • No image
    March 15, 20240Single linkage hierarchical clustering
  • No image
    April 17, 20240XGBoost (eXtreme Gradient Boosting)
  • No image
    April 17, 20240Gradient Boosting
  • No image
    March 15, 2024Unsupervised Learning Dimensionality Reduction – Feature Elimination…
  • No image
    February 11, 2024How-to: save a Google Colab notebook as…
  • No image
    March 11, 2024What is Silhouette Coefficient
  • Implementation (55)
    • EDA (4)
    • Neural Networks (10)
    • Supervised Learning (26)
      • Classification (17)
      • Linear Regression (8)
    • Unsupervised Learning (11)
      • Clustering (8)
      • Dimensionality Reduction (3)
  • Knowledge Base (44)
    • Python (27)
    • Statistics (6)
May 2025
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Oct    

We are on

FacebookTwitterLinkedinYouTubeGitHubSubscribeEmailRSS

Subscribe

© 2025 Beyond Knowledge Innovation
FacebookTwitterLinkedinYouTubeGitHubSubscribeEmailRSS