junaid008 commited on
Commit
a161d95
·
verified ·
1 Parent(s): 2a9ba1b

pakdata 0.1.0: pak_crops

Browse files
Files changed (2) hide show
  1. README.md +172 -0
  2. data/train.parquet +3 -0
README.md ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ pretty_name: "Pakistan crop statistics: area, production and yield of 79 crops, 1961-2024 (FAOSTAT)"
4
+ language:
5
+ - en
6
+ task_categories:
7
+ - tabular-regression
8
+ tags:
9
+ - pakistan
10
+ - pakdata
11
+ - tabular
12
+ - agriculture
13
+ - crops
14
+ - faostat
15
+ - food-security
16
+ size_categories:
17
+ - 1K<n<10K
18
+ configs:
19
+ - config_name: default
20
+ data_files:
21
+ - split: train
22
+ path: data/train.parquet
23
+ ---
24
+
25
+ # Pakistan crop statistics: area, production and yield of 79 crops, 1961-2024 (FAOSTAT)
26
+
27
+ Part of **[pakdata](https://github.com/junaidaslam2006/pakData)**, a collection of real, openly licensed Pakistan-specific datasets for machine learning.
28
+ Every value comes from the named public source below; nothing is synthetic or AI-generated.
29
+
30
+ | | |
31
+ |---|---|
32
+ | Rows | 4,202 |
33
+ | Default target | `yield_kg_per_ha` (regression) |
34
+ | Source | FAO (FAOSTAT, Production: Crops and livestock products, QCL) |
35
+ | License | CC BY 4.0 (FAO Statistical Database Terms of Use) |
36
+ | Snapshot | 2026.11 |
37
+
38
+ ## Load it
39
+
40
+ ```python
41
+ # Hugging Face datasets
42
+ from datasets import load_dataset
43
+ ds = load_dataset("junaid008/pak_crops", split="train")
44
+ df = ds.to_pandas()
45
+
46
+ # pandas only
47
+ import pandas as pd
48
+ df = pd.read_parquet("hf://datasets/junaid008/pak_crops/data/train.parquet")
49
+
50
+ # pakdata (scikit-learn style, works offline) pip install pakdata
51
+ from pakdata import load_pak_crops
52
+ X, y = load_pak_crops(return_X_y=True)
53
+ ```
54
+
55
+ **Features used by `pakdata`:** `crop`, `crop_group`, `year`, `area_harvested_ha`, `area_harvested_flag`
56
+
57
+ **Kept in the table but not used as features** (ids, raw dates, or columns that would leak the target): `fao_item_code`, `production_tonnes`, `production_flag`, `yield_flag`
58
+
59
+ ## Data card
60
+
61
+ The full data card (column meanings and units, how it was built, caveats, suggested tasks):
62
+
63
+ ```text
64
+ .. _pak_crops_dataset:
65
+
66
+ Pakistan crop statistics (FAOSTAT), 1961-2024
67
+ ---------------------------------------------
68
+
69
+ Harvested area, production and yield of every primary crop FAO reports for
70
+ Pakistan, one row per (crop, year), with FAO's data-quality flag on every value.
71
+
72
+ **Data Set Characteristics:**
73
+
74
+ :Number of Instances: 4202 (79 crops x up to 64 years)
75
+ :Number of Attributes: 5 features (``crop``, ``crop_group``, ``year``, ``area_harvested_ha``, ``area_harvested_flag``) + target; 4 more columns kept in ``frame`` only
76
+ :Default target: ``yield_kg_per_ha`` (kg per hectare)
77
+ :Time coverage: 1961-2024 (annual; coverage varies by crop, see Caveats)
78
+ :Geographic coverage: Pakistan, national totals (FAO area code 165); no provincial breakdown
79
+ :Source: Food and Agriculture Organization of the United Nations (FAO), FAOSTAT domain QCL "Production: Crops and livestock products", last updated 2025-12-31. https://www.fao.org/faostat/en/#data/QCL ; bulk file https://bulks-faostat.fao.org/production/Production_Crops_Livestock_E_Asia.zip
80
+ :License: CC BY 4.0, complemented by the FAO Statistical Database Terms of Use, https://www.fao.org/contact-us/terms/db-terms-of-use/en/ (redistribution permitted with attribution; no implied FAO endorsement; no commercial promotion)
81
+ :Snapshot: 2026.11 (retrieved 2026-11-29)
82
+
83
+ **Columns:**
84
+
85
+ - ``crop`` (category): FAO item name exactly as published, e.g. ``Wheat``, ``Rice`` (= rice paddy), ``Seed cotton, unginned``, ``Sugar cane``, ``Maize (corn)``, ``Chick peas, dry``, ``Mangoes, guavas and mangosteens``, ``Tangerines, mandarins, clementines`` (FAO's item for kinnow), ``Oranges``, ``Dates``, ``Potatoes``, ``Onions and shallots, dry (excluding dehydrated)``.
86
+ - ``crop_group`` (category): pakdata grouping of the FAO item, following FAOSTAT's commodity aggregates: ``cereal`` (6 crops), ``pulse`` (6), ``fibre`` (3), ``sugar`` (2), ``oilseed`` (12, includes coconuts and olives, as in FAO "Oilcrops"), ``root_tuber`` (3), ``vegetable`` (17, includes melons and watermelons), ``fruit`` (22), ``tree_nut`` (4), ``spice`` (3), ``stimulant`` (1, tobacco). This is the only column not taken from FAO.
87
+ - ``fao_item_code`` (int): FAOSTAT item code (identifier; excluded from features).
88
+ - ``year`` (int): calendar year of the FAO record.
89
+ - ``area_harvested_ha`` (hectares): area harvested.
90
+ - ``area_harvested_flag`` (category): FAO flag for the area value.
91
+ - ``production_tonnes`` (tonnes): production quantity. **Excluded from features**: FAO's yield is production / area, so production and area together give the target exactly.
92
+ - ``production_flag`` (category): FAO flag for production (excluded from features).
93
+ - ``yield_kg_per_ha`` (kg/ha): yield as published by FAO (target).
94
+ - ``yield_flag`` (category): FAO flag for yield (excluded from features, it describes the target).
95
+
96
+ FAO flag codes: ``A`` = official figure; ``E`` = estimated value (FAO estimate);
97
+ ``I`` = value imputed by a receiving agency; ``X`` = figure from an external
98
+ organization (in this file every ``X`` yield/production value from the early
99
+ decades is also annotated by FAO as an "unofficial figure"; that note is not
100
+ kept as a column). Counts in this file:
101
+
102
+ - ``yield_flag``: A 3626, E 365, X 211
103
+ - ``area_harvested_flag``: A 3635, E 240, X 218, I 109
104
+ - ``production_flag``: A 3639, X 226, E 204, I 133
105
+
106
+ So about 86% of yields are official figures. Estimated or external yields are
107
+ concentrated in minor fruits, vegetables, nuts and spices and in the 1960s-70s;
108
+ the staple crops (wheat, rice, seed cotton, sugar cane, chickpeas, mangoes,
109
+ potatoes, onions) are official (``A``) in every year; maize and dates have one
110
+ non-official year each. Oranges (1961-1990) and tangerines/kinnow (most years)
111
+ are mainly ``X``. Filter with ``frame[frame.yield_flag == "A"]`` to use official
112
+ figures only.
113
+
114
+ **How it was built:** ``scripts/build_pak_crops.py`` downloads FAO's QCL bulk file
115
+ for Asia (wide format with flags), keeps rows for Pakistan (area code 165) and the
116
+ elements Area harvested (5312, ha), Production (5510, t) and Yield (5412, kg/ha),
117
+ keeps the 79 items that have an area-harvested element (primary crops) and drops
118
+ FAO aggregate items (codes >= 1700, e.g. "Cereals, primary") and livestock. The
119
+ wide year columns are reshaped to one row per (crop, year). 438 crop-years for
120
+ which FAO publishes no yield were dropped: in all of them FAO reports a zero
121
+ harvested area (408, mostly 1961-1981 for vegetables and minor fruits that were not
122
+ reported separately then) or no area at all (30, "Other oil seeds" 1961-1990).
123
+ No value was filled, interpolated or recomputed. Rows are sorted by ``crop``, ``year``.
124
+
125
+ **Caveats and known biases:**
126
+
127
+ - National totals only; reporting conventions changed over time (e.g. many vegetables
128
+ start in 1980, newly reported fruits such as olives, persimmons, strawberries and
129
+ grapefruit appear only after 2016). ``Oranges`` has a gap 1991-2015.
130
+ A crop's first year in the file is where FAO starts reporting it, not when it was first grown.
131
+ - Kinnow, Pakistan's main citrus, is recorded by FAO under
132
+ ``Tangerines, mandarins, clementines``; ``Mangoes, guavas and mangosteens`` mixes
133
+ three fruits; ``... n.e.c.`` items are residual groups of many minor crops.
134
+ - FAO yields are computed from production and area; for a few small crops with
135
+ rounded areas, ``production_tonnes / area_harvested_ha * 1000`` differs from
136
+ ``yield_kg_per_ha`` by up to ~11%.
137
+ - FAO figures can differ from Pakistan Bureau of Statistics / Ministry of National
138
+ Food Security figures (e.g. fiscal-year vs calendar-year attribution); FAO revises
139
+ past values between releases.
140
+ - Yields span 219 to 74,252 kg/ha across crops (cereals vs. sugar cane/vegetables),
141
+ so crop identity alone explains most of the variance: a per-crop mean of
142
+ log-yield already gives R^2 ~0.94 under random 5-fold CV. Model ``log(yield)``
143
+ and evaluate with a time-based split (train on earlier years, test on later
144
+ ones) or within crops. A random row split lets the model interpolate between
145
+ neighbouring years of the same crop, which flatters the score.
146
+ - No weather, irrigation, fertiliser or price variables are included.
147
+
148
+ **Suggested tasks:**
149
+
150
+ 1. Regression (beginner): predict ``log(yield_kg_per_ha)`` from ``crop``, ``year`` and
151
+ ``area_harvested_ha``; train on years <= 2014, test on 2015-2024. A
152
+ one-hot + RandomForest baseline gives R^2 ~0.92 on the log scale.
153
+ 2. Time series (intermediate): forecast wheat, rice or seed-cotton yield one year ahead
154
+ from lagged yields; compare against a naive "last year" forecast.
155
+ 3. Clustering: build a crop x year matrix of standardised yield trends and cluster
156
+ crops by growth pattern (e.g. Green Revolution cereals vs. stagnant pulses).
157
+ 4. Classification / data quality: predict whether a value is official (``yield_flag == "A"``)
158
+ from crop group, year and area, and discuss why missing-data mechanisms matter.
159
+
160
+ **Citation / attribution:**
161
+
162
+ FAO. 2025. FAOSTAT: Production: Crops and livestock products. Accessed on 29 November 2026. https://www.fao.org/faostat/en/#data/QCL. Licence: CC-BY-4.0.
163
+
164
+ Use of this data does not imply any endorsement by FAO of pakdata or of any
165
+ analysis made with it.
166
+ ```
167
+
168
+ ## Citation and attribution
169
+
170
+ FAO. 2025. FAOSTAT: Production: Crops and livestock products. Accessed on 29 November 2026. https://www.fao.org/faostat/en/#data/QCL. Licence: CC-BY-4.0.
171
+
172
+ Packaged by pakdata (https://github.com/junaidaslam2006/pakData). Build script: [`scripts/build_pak_crops.py`](https://github.com/junaidaslam2006/pakData/blob/main/scripts/build_pak_crops.py).
data/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:599b12e403e623a402547f031bf3640fe3f9d94483bc56a530e15ff4169de4ca
3
+ size 84741