In [1]:
import pandas as pd
import numpy as np

columns = ["State","State_ANSI", "Ag_District", "Ag_District_Code", "County", 
           "County_ANSI","Commodity","Data_Item", "Domain", "Domain_Category", "Value", "CV", "FIPS"]

path = 'fruit_by_county.csv'

fruit_df = pd.read_csv(path, names=columns, skiprows=1)

In [2]:
# make strings to concatenate into FIPS codes
fruit_df.State_ANSI = fruit_df.State_ANSI.astype(str)
fruit_df.County_ANSI = fruit_df.County_ANSI.astype(str)

# more readable in title case than all caps
fruit_df.State = fruit_df.apply(lambda x: x.State.title(), axis = 1)
fruit_df.County = fruit_df.apply(lambda x: x.County.title(), axis = 1)
fruit_df.Commodity = fruit_df.apply(lambda x: x.Commodity.title(), axis = 1)

In [3]:
def prepend_zeros(row):
    if len(row.County_ANSI) == 1:
        return ''.join(['00', row.County_ANSI])
    elif len(row.County_ANSI) == 2:
        return ''.join(['0', row.County_ANSI])
    else:
        return row.County_ANSI

fruit_df.County_ANSI = fruit_df.apply(prepend_zeros, axis=1)

In [5]:
# index by combined ids
fruit_df.FIPS = fruit_df.apply(lambda row: ''.join([row.State_ANSI, row.County_ANSI]), axis = 1)
fruit_df.head()


Out[5]:
State State_ANSI Ag_District Ag_District_Code County County_ANSI Commodity Data_Item Domain Domain_Category Value CV FIPS
0 Alabama 1 BLACK BELT 40 Autauga 001 Apples APPLES - ACRES BEARING TOTAL NOT SPECIFIED (D) (D) 1001
1 Alabama 1 BLACK BELT 40 Autauga 001 Apples APPLES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 60.2 1001
2 Alabama 1 BLACK BELT 40 Autauga 001 Grapes GRAPES - ACRES BEARING TOTAL NOT SPECIFIED (D) (D) 1001
3 Alabama 1 BLACK BELT 40 Autauga 001 Grapes GRAPES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 38.6 1001
4 Alabama 1 BLACK BELT 40 Autauga 001 Non-Citrus Totals NON-CITRUS TOTALS, (EXCL BERRIES) - ACRES BEARING TOTAL NOT SPECIFIED 33 35.8 1001

5 rows × 13 columns


In [6]:
fruit_df2 = fruit_df.Data_Item.apply(lambda x: pd.Series(x.split('- ')))
fruit_df2.columns = ['Spec_Commodity', 'Measure']
fruit_df2.head()


Out[6]:
Spec_Commodity Measure
0 APPLES ACRES BEARING
1 APPLES OPERATIONS WITH AREA BEARING
2 GRAPES ACRES BEARING
3 GRAPES OPERATIONS WITH AREA BEARING
4 NON-CITRUS TOTALS, (EXCL BERRIES) ACRES BEARING

5 rows × 2 columns


In [7]:
fruit_df3 = pd.merge(fruit_df, fruit_df2, left_index= True, right_index= True)

In [8]:
fruit_df3.head()


Out[8]:
State State_ANSI Ag_District Ag_District_Code County County_ANSI Commodity Data_Item Domain Domain_Category Value CV FIPS Spec_Commodity Measure
0 Alabama 1 BLACK BELT 40 Autauga 001 Apples APPLES - ACRES BEARING TOTAL NOT SPECIFIED (D) (D) 1001 APPLES ACRES BEARING
1 Alabama 1 BLACK BELT 40 Autauga 001 Apples APPLES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 60.2 1001 APPLES OPERATIONS WITH AREA BEARING
2 Alabama 1 BLACK BELT 40 Autauga 001 Grapes GRAPES - ACRES BEARING TOTAL NOT SPECIFIED (D) (D) 1001 GRAPES ACRES BEARING
3 Alabama 1 BLACK BELT 40 Autauga 001 Grapes GRAPES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 38.6 1001 GRAPES OPERATIONS WITH AREA BEARING
4 Alabama 1 BLACK BELT 40 Autauga 001 Non-Citrus Totals NON-CITRUS TOTALS, (EXCL BERRIES) - ACRES BEARING TOTAL NOT SPECIFIED 33 35.8 1001 NON-CITRUS TOTALS, (EXCL BERRIES) ACRES BEARING

5 rows × 15 columns


In [14]:
# isolate Value column for rows that correspond to fresh market acres harvested, create boolean mask
test_series = fruit_df3[fruit_df3.Measure == "ACRES BEARING"].Value.str.contains("(D)")

# proportion of True/Total
float(np.sum(test_series))/len(test_series)


Out[14]:
0.6497700562084824

Would have liked to use acres bearing, but 65% of that data has been withheld, as denoted by '(D)' values in Value column.

From USDA Census Report, Appendix A:

DISCLOSURE REVIEW

After tabulation and review of the aggregates, a comprehensive disclosure review was conducted. NASS is obligated to withhold, under Title 7, U.S. Code, any total that would reveal an individual’s information or allow it to be closely estimated by the public. Cell suppression was used to protect the cells that were determined to be sensitive to a disclosure of information. Farm counts are not considered sensitive and are not subject to disclosure controls.

Based on agency standards, data cells were determined to be sensitive to a disclosure of information if they violated either of two criteria rules. The threshold rule was violated if the data cell contained less than three operations. For example, if only one farmer produced turkeys in a county, NASS could not publish the county total for turkey inventory without disclosing that individual’s information. The dominance rule was violated if the distribution of the data within the cell allowed a data user to estimate any respondent’s data too closely. For example, if there are many farmers producing turkeys in a county and some of them were large enough to dominate the cell total, NASS could not publish the county total for turkey inventory without risking disclosing an individual respondent’s data. In both of these situations, the data were suppressed and a “(D)” was placed in the cell in the census publication table. These data cells were referred to as primary suppressions.


In [ ]:
# IF WANT TO USE ACRES HARVESTED: replace null code Values (such as '(D)','(Z)', etc) with 0
#fruit_df3.Value = fruit_df3.Value.replace(to_replace = r'([A-Z+])', value = 0, regex=True)

In [22]:
fruit_df4 = fruit_df3[fruit_df3.Measure == "OPERATIONS WITH AREA BEARING"]
fruit_df4.head()


Out[22]:
State State_ANSI Ag_District Ag_District_Code County County_ANSI Commodity Data_Item Domain Domain_Category Value CV FIPS Spec_Commodity Measure
1 Alabama 1 BLACK BELT 40 Autauga 001 Apples APPLES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 60.2 1001 APPLES OPERATIONS WITH AREA BEARING
3 Alabama 1 BLACK BELT 40 Autauga 001 Grapes GRAPES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 38.6 1001 GRAPES OPERATIONS WITH AREA BEARING
5 Alabama 1 BLACK BELT 40 Autauga 001 Non-Citrus Totals NON-CITRUS TOTALS, (EXCL BERRIES) - OPERATIONS... TOTAL NOT SPECIFIED 9 24.5 1001 NON-CITRUS TOTALS, (EXCL BERRIES) OPERATIONS WITH AREA BEARING
7 Alabama 1 BLACK BELT 40 Autauga 001 Peaches PEACHES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 5 19.3 1001 PEACHES OPERATIONS WITH AREA BEARING
9 Alabama 1 BLACK BELT 40 Autauga 001 Pears PEARS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 48.4 1001 PEARS OPERATIONS WITH AREA BEARING

5 rows × 15 columns


In [24]:
# replace null values with 0
fruit_df4.Value = fruit_df4.Value.fillna(0)

fruit_df4.Value = fruit_df4.Value.replace(to_replace = ',', value = '', regex=True)

In [25]:
fruit_df4.Value = fruit_df4.Value.astype(int)
fruit_df4.FIPS = fruit_df4.FIPS.astype(int)

In [26]:
fruit_df4.head()


Out[26]:
State State_ANSI Ag_District Ag_District_Code County County_ANSI Commodity Data_Item Domain Domain_Category Value CV FIPS Spec_Commodity Measure
1 Alabama 1 BLACK BELT 40 Autauga 001 Apples APPLES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 60.2 1001 APPLES OPERATIONS WITH AREA BEARING
3 Alabama 1 BLACK BELT 40 Autauga 001 Grapes GRAPES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 38.6 1001 GRAPES OPERATIONS WITH AREA BEARING
5 Alabama 1 BLACK BELT 40 Autauga 001 Non-Citrus Totals NON-CITRUS TOTALS, (EXCL BERRIES) - OPERATIONS... TOTAL NOT SPECIFIED 9 24.5 1001 NON-CITRUS TOTALS, (EXCL BERRIES) OPERATIONS WITH AREA BEARING
7 Alabama 1 BLACK BELT 40 Autauga 001 Peaches PEACHES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 5 19.3 1001 PEACHES OPERATIONS WITH AREA BEARING
9 Alabama 1 BLACK BELT 40 Autauga 001 Pears PEARS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 48.4 1001 PEARS OPERATIONS WITH AREA BEARING

5 rows × 15 columns


In [27]:
# check out California fruitgies
fruit_df4[fruit_df4.State == 'California'].head(50)


Out[27]:
State State_ANSI Ag_District Ag_District_Code County County_ANSI Commodity Data_Item Domain Domain_Category Value CV FIPS Spec_Commodity Measure
2341 California 6 CENTRAL COAST 40 Alameda 001 Almonds ALMONDS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 5 4.1 6001 ALMONDS OPERATIONS WITH AREA BEARING
2343 California 6 CENTRAL COAST 40 Alameda 001 Apples APPLES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 12.7 6001 APPLES OPERATIONS WITH AREA BEARING
2345 California 6 CENTRAL COAST 40 Alameda 001 Apricots APRICOTS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 7 18.2 6001 APRICOTS OPERATIONS WITH AREA BEARING
2347 California 6 CENTRAL COAST 40 Alameda 001 Citrus Totals CITRUS TOTALS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 6 6001 CITRUS TOTALS OPERATIONS WITH AREA BEARING
2349 California 6 CENTRAL COAST 40 Alameda 001 Grapes GRAPES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 74 4.8 6001 GRAPES OPERATIONS WITH AREA BEARING
2351 California 6 CENTRAL COAST 40 Alameda 001 Lemons LEMONS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 8.9 6001 LEMONS OPERATIONS WITH AREA BEARING
2353 California 6 CENTRAL COAST 40 Alameda 001 Non-Citrus Totals NON-CITRUS TOTALS, (EXCL BERRIES) - OPERATIONS... TOTAL NOT SPECIFIED 93 6.1 6001 NON-CITRUS TOTALS, (EXCL BERRIES) OPERATIONS WITH AREA BEARING
2355 California 6 CENTRAL COAST 40 Alameda 001 Non-Citrus, Other NON-CITRUS, OTHER, (EXCL BERRIES) - OPERATIONS... TOTAL NOT SPECIFIED 2 13.8 6001 NON-CITRUS, OTHER, (EXCL BERRIES) OPERATIONS WITH AREA BEARING
2357 California 6 CENTRAL COAST 40 Alameda 001 Olives OLIVES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 6 8.8 6001 OLIVES OPERATIONS WITH AREA BEARING
2359 California 6 CENTRAL COAST 40 Alameda 001 Oranges ORANGES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 5.4 6001 ORANGES OPERATIONS WITH AREA BEARING
2361 California 6 CENTRAL COAST 40 Alameda 001 Oranges ORANGES, MID & NAVEL - OPERATIONS WITH AREA BE... TOTAL NOT SPECIFIED 2 4.8 6001 ORANGES, MID & NAVEL OPERATIONS WITH AREA BEARING
2363 California 6 CENTRAL COAST 40 Alameda 001 Persimmons PERSIMMONS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 13.7 6001 PERSIMMONS OPERATIONS WITH AREA BEARING
2365 California 6 CENTRAL COAST 40 Alameda 001 Pistachios PISTACHIOS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 4 10.7 6001 PISTACHIOS OPERATIONS WITH AREA BEARING
2367 California 6 CENTRAL COAST 40 Alameda 001 Plums PLUMS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 8.2 6001 PLUMS OPERATIONS WITH AREA BEARING
2369 California 6 CENTRAL COAST 40 Alameda 001 Plums & Prunes PLUMS & PRUNES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 8.3 6001 PLUMS & PRUNES OPERATIONS WITH AREA BEARING
2371 California 6 CENTRAL COAST 40 Alameda 001 Pomegranates POMEGRANATES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 3 10.1 6001 POMEGRANATES OPERATIONS WITH AREA BEARING
2373 California 6 CENTRAL COAST 40 Alameda 001 Tree Nut Totals TREE NUT TOTALS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 9 4.4 6001 TREE NUT TOTALS OPERATIONS WITH AREA BEARING
2375 California 6 CENTRAL COAST 40 Contra Costa 013 Almonds ALMONDS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 4 4.1 6013 ALMONDS OPERATIONS WITH AREA BEARING
2377 California 6 CENTRAL COAST 40 Contra Costa 013 Apples APPLES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 15 12.7 6013 APPLES OPERATIONS WITH AREA BEARING
2379 California 6 CENTRAL COAST 40 Contra Costa 013 Apricots APRICOTS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 24 18.2 6013 APRICOTS OPERATIONS WITH AREA BEARING
2381 California 6 CENTRAL COAST 40 Contra Costa 013 Cherries CHERRIES, SWEET - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 24 13.4 6013 CHERRIES, SWEET OPERATIONS WITH AREA BEARING
2383 California 6 CENTRAL COAST 40 Contra Costa 013 Citrus Totals CITRUS TOTALS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 9 6 6013 CITRUS TOTALS OPERATIONS WITH AREA BEARING
2385 California 6 CENTRAL COAST 40 Contra Costa 013 Citrus, Other CITRUS, OTHER - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 5 21.7 6013 CITRUS, OTHER OPERATIONS WITH AREA BEARING
2387 California 6 CENTRAL COAST 40 Contra Costa 013 Figs FIGS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 38.8 6013 FIGS OPERATIONS WITH AREA BEARING
2389 California 6 CENTRAL COAST 40 Contra Costa 013 Grapes GRAPES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 97 4.8 6013 GRAPES OPERATIONS WITH AREA BEARING
2391 California 6 CENTRAL COAST 40 Contra Costa 013 Lemons LEMONS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 5 8.9 6013 LEMONS OPERATIONS WITH AREA BEARING
2393 California 6 CENTRAL COAST 40 Contra Costa 013 Nectarines NECTARINES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 12 9.3 6013 NECTARINES OPERATIONS WITH AREA BEARING
2395 California 6 CENTRAL COAST 40 Contra Costa 013 Non-Citrus Totals NON-CITRUS TOTALS, (EXCL BERRIES) - OPERATIONS... TOTAL NOT SPECIFIED 163 6.1 6013 NON-CITRUS TOTALS, (EXCL BERRIES) OPERATIONS WITH AREA BEARING
2397 California 6 CENTRAL COAST 40 Contra Costa 013 Non-Citrus, Other NON-CITRUS, OTHER, (EXCL BERRIES) - OPERATIONS... TOTAL NOT SPECIFIED 7 13.8 6013 NON-CITRUS, OTHER, (EXCL BERRIES) OPERATIONS WITH AREA BEARING
2399 California 6 CENTRAL COAST 40 Contra Costa 013 Olives OLIVES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 10 8.8 6013 OLIVES OPERATIONS WITH AREA BEARING
2401 California 6 CENTRAL COAST 40 Contra Costa 013 Oranges ORANGES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 8 5.4 6013 ORANGES OPERATIONS WITH AREA BEARING
2403 California 6 CENTRAL COAST 40 Contra Costa 013 Oranges ORANGES, MID & NAVEL - OPERATIONS WITH AREA BE... TOTAL NOT SPECIFIED 8 4.8 6013 ORANGES, MID & NAVEL OPERATIONS WITH AREA BEARING
2405 California 6 CENTRAL COAST 40 Contra Costa 013 Oranges ORANGES, VALENCIA - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 7.3 6013 ORANGES, VALENCIA OPERATIONS WITH AREA BEARING
2407 California 6 CENTRAL COAST 40 Contra Costa 013 Peaches PEACHES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 37 8.7 6013 PEACHES OPERATIONS WITH AREA BEARING
2409 California 6 CENTRAL COAST 40 Contra Costa 013 Peaches PEACHES, CLINGSTONE - OPERATIONS WITH AREA BEA... TOTAL NOT SPECIFIED 6 14.5 6013 PEACHES, CLINGSTONE OPERATIONS WITH AREA BEARING
2411 California 6 CENTRAL COAST 40 Contra Costa 013 Peaches PEACHES, FREESTONE - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 35 11.8 6013 PEACHES, FREESTONE OPERATIONS WITH AREA BEARING
2413 California 6 CENTRAL COAST 40 Contra Costa 013 Pears PEARS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 4 22.1 6013 PEARS OPERATIONS WITH AREA BEARING
2415 California 6 CENTRAL COAST 40 Contra Costa 013 Pears PEARS, (EXCL BARTLETT) - OPERATIONS WITH AREA ... TOTAL NOT SPECIFIED 4 26.4 6013 PEARS, (EXCL BARTLETT) OPERATIONS WITH AREA BEARING
2417 California 6 CENTRAL COAST 40 Contra Costa 013 Persimmons PERSIMMONS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 9 13.7 6013 PERSIMMONS OPERATIONS WITH AREA BEARING
2419 California 6 CENTRAL COAST 40 Contra Costa 013 Pistachios PISTACHIOS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 3 10.7 6013 PISTACHIOS OPERATIONS WITH AREA BEARING
2421 California 6 CENTRAL COAST 40 Contra Costa 013 Plum-Apricot Hybrids PLUM-APRICOT HYBRIDS, INCL PLUMCOTS & PLUOTS -... TOTAL NOT SPECIFIED 5 20 6013 PLUM-APRICOT HYBRIDS, INCL PLUMCOTS & PLUOTS OPERATIONS WITH AREA BEARING
2423 California 6 CENTRAL COAST 40 Contra Costa 013 Plums PLUMS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 8 8.2 6013 PLUMS OPERATIONS WITH AREA BEARING
2425 California 6 CENTRAL COAST 40 Contra Costa 013 Plums & Prunes PLUMS & PRUNES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 9 8.3 6013 PLUMS & PRUNES OPERATIONS WITH AREA BEARING
2427 California 6 CENTRAL COAST 40 Contra Costa 013 Pomegranates POMEGRANATES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 7 10.1 6013 POMEGRANATES OPERATIONS WITH AREA BEARING
2429 California 6 CENTRAL COAST 40 Contra Costa 013 Prunes PRUNES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 5 11.9 6013 PRUNES OPERATIONS WITH AREA BEARING
2431 California 6 CENTRAL COAST 40 Contra Costa 013 Tree Nut Totals TREE NUT TOTALS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 38 4.4 6013 TREE NUT TOTALS OPERATIONS WITH AREA BEARING
2433 California 6 CENTRAL COAST 40 Contra Costa 013 Tree Nuts, Other TREE NUTS, OTHER - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 1 39.5 6013 TREE NUTS, OTHER OPERATIONS WITH AREA BEARING
2435 California 6 CENTRAL COAST 40 Contra Costa 013 Walnuts WALNUTS, ENGLISH - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 30 5.9 6013 WALNUTS, ENGLISH OPERATIONS WITH AREA BEARING
2437 California 6 CENTRAL COAST 40 Lake 033 Almonds ALMONDS - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 2 4.1 6033 ALMONDS OPERATIONS WITH AREA BEARING
2439 California 6 CENTRAL COAST 40 Lake 033 Apples APPLES - OPERATIONS WITH AREA BEARING TOTAL NOT SPECIFIED 19 12.7 6033 APPLES OPERATIONS WITH AREA BEARING

50 rows × 15 columns


In [28]:
# Create pivot table
fruit_pt = pd.pivot_table(fruit_df4, values = 'Value', rows = 'FIPS', cols= 'Commodity', aggfunc = np.sum)

Lots of NaN values in the pivot table. Will convert to zeros.


In [29]:
fruit_pt.head()


Out[29]:
Commodity Almonds Apples Apricots Avocados Bananas Cherries Chestnuts Citrus Totals Citrus, Other Coffee Dates Figs Grapefruit Grapes Guavas Hazelnuts Kiwifruit Kumquats Lemons Limes
FIPS
1001 NaN 1 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 NaN NaN NaN NaN NaN NaN ...
1003 NaN 2 NaN NaN NaN NaN NaN 22 21 NaN NaN 2 NaN 8 NaN NaN NaN NaN NaN NaN ...
1005 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 NaN 3 NaN NaN NaN NaN NaN NaN ...
1007 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 2 NaN NaN NaN NaN NaN NaN ...
1009 NaN 4 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 5 NaN NaN NaN NaN NaN NaN ...

5 rows × 45 columns


In [30]:
fruit_pt = fruit_pt.fillna(0)
fruit_pt.head()


Out[30]:
Commodity Almonds Apples Apricots Avocados Bananas Cherries Chestnuts Citrus Totals Citrus, Other Coffee Dates Figs Grapefruit Grapes Guavas Hazelnuts Kiwifruit Kumquats Lemons Limes
FIPS
1001 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 ...
1003 0 2 0 0 0 0 0 22 21 0 0 2 0 8 0 0 0 0 0 0 ...
1005 0 0 0 0 0 0 0 0 0 0 0 1 0 3 0 0 0 0 0 0 ...
1007 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 ...
1009 0 4 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 ...

5 rows × 45 columns


In [31]:
fruit_pt.to_csv('fruit.csv')