Engineer786 commited on
Commit
aae20ec
·
verified ·
1 Parent(s): d77a54b

Update tariff_scraper.py

Browse files
Files changed (1) hide show
  1. tariff_scraper.py +5 -2
tariff_scraper.py CHANGED
@@ -43,10 +43,13 @@ def scrape_multiple_sections_to_csv(url, output_file="pesco_tariff_data.csv"):
43
  data.append(cols)
44
 
45
  # Create a dataframe for the current table
46
- df = pd.DataFrame(data[1:], columns=data[0]) if len(data) > 1 else pd.DataFrame(data)
 
 
 
47
 
48
  # Ensure column names are unique
49
- df.columns = pd.Series(df.columns).apply(lambda x: x if df.columns.tolist().count(x) == 1 else f"{x}_{df.columns.tolist().count(x)}")
50
 
51
  # Add a section identifier
52
  df["Section"] = f"Section {i}"
 
43
  data.append(cols)
44
 
45
  # Create a dataframe for the current table
46
+ if len(data) > 1:
47
+ df = pd.DataFrame(data[1:], columns=data[0])
48
+ else:
49
+ df = pd.DataFrame(data)
50
 
51
  # Ensure column names are unique
52
+ df.columns = pd.io.parsers.ParserBase({'names': df.columns})._maybe_dedup_names()
53
 
54
  # Add a section identifier
55
  df["Section"] = f"Section {i}"