amylonidis commited on
Commit
9691a02
·
verified ·
1 Parent(s): 4b22e4d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -9
README.md CHANGED
@@ -77,23 +77,23 @@ that were published from March until April in 1985.
77
  import pandas as pd
78
  from datetime import datetime
79
 
80
- def load_csvs_from_huggingface( start_date, end_date):
81
  """
82
  Load only the necessary CSV files from a Hugging Face dataset repository.
83
 
84
- :param start_year: int, the start year (inclusive)
85
- :param end_year: int, the end year (inclusive)
86
 
87
  :return: pd.DataFrame, combined data from selected CSVs
88
  """
89
-
90
 
91
  column_types = {
92
  "ucid": "string",
93
  "country": "category",
94
  "doc_number": "int64",
95
  "kind": "category",
96
- "lang": "category",,
97
  "date": "int32",
98
  "application_date": "int32",
99
  "date_produced": "int32",
@@ -119,9 +119,7 @@ def load_csvs_from_huggingface( start_date, end_date):
119
  end_date_int = int(datetime.strptime(end_date, "%Y-%m-%d").strftime("%Y%m%d"))
120
 
121
  start_year, end_year = str(start_date_int)[:4], str(end_date_int)[:4]
122
-
123
  given_years = [str(year) for year in range(int(start_year), int(end_year) + 1)]
124
-
125
  matching_years = [f for f in dataset_years for year in given_years if f==year]
126
 
127
  if not matching_years:
@@ -130,10 +128,9 @@ def load_csvs_from_huggingface( start_date, end_date):
130
  df_list = []
131
  for year in matching_years:
132
  filepath = f"data/years/{year}/clefip2011_en_classification_{year}_validated.csv"
133
- print(filepath)
134
 
135
  try:
136
- dataset = load_dataset("amylonidis/PatClass2011", data_files=filepath)
137
  df = dataset["train"].to_pandas().astype(column_types)
138
  df_list.append(df)
139
  except Exception as e:
@@ -148,6 +145,7 @@ def load_csvs_from_huggingface( start_date, end_date):
148
  else:
149
  return pd.DataFrame()
150
 
 
151
  ```
152
 
153
  ```python
 
77
  import pandas as pd
78
  from datetime import datetime
79
 
80
+ def load_csvs_from_huggingface(start_date, end_date):
81
  """
82
  Load only the necessary CSV files from a Hugging Face dataset repository.
83
 
84
+ :param start_date: str, the start date in 'YYYY-MM-DD' format (inclusive)
85
+ :param end_date: str, the end date in 'YYYY-MM-DD' format (inclusive)
86
 
87
  :return: pd.DataFrame, combined data from selected CSVs
88
  """
89
+ huggingface_dataset_name = "amylonidis/PatClass2011"
90
 
91
  column_types = {
92
  "ucid": "string",
93
  "country": "category",
94
  "doc_number": "int64",
95
  "kind": "category",
96
+ "lang": "category",
97
  "date": "int32",
98
  "application_date": "int32",
99
  "date_produced": "int32",
 
119
  end_date_int = int(datetime.strptime(end_date, "%Y-%m-%d").strftime("%Y%m%d"))
120
 
121
  start_year, end_year = str(start_date_int)[:4], str(end_date_int)[:4]
 
122
  given_years = [str(year) for year in range(int(start_year), int(end_year) + 1)]
 
123
  matching_years = [f for f in dataset_years for year in given_years if f==year]
124
 
125
  if not matching_years:
 
128
  df_list = []
129
  for year in matching_years:
130
  filepath = f"data/years/{year}/clefip2011_en_classification_{year}_validated.csv"
 
131
 
132
  try:
133
+ dataset = load_dataset(huggingface_dataset_name, data_files=filepath)
134
  df = dataset["train"].to_pandas().astype(column_types)
135
  df_list.append(df)
136
  except Exception as e:
 
145
  else:
146
  return pd.DataFrame()
147
 
148
+
149
  ```
150
 
151
  ```python