Unused variable 'fig'
641 northumbriaData1 = (
642 northumbria2020Dataset.groupby(["age_range", "gender"]).std().unstack()
643 )
644 fig, (ax0, ax1) = plt.subplots(645 nrows=2, ncols=1, sharey=True, figsize=(10, 10)
646 )
647 northumbriaData0.plot(kind="barh", y="day", ax=ax0)
Unused variable 'fig'
590 .mean()
591 .unstack()
592 )
593 fig, (ax0, ax1) = plt.subplots(594 nrows=2, ncols=1, sharey=True, figsize=(30, 10)
595 )
596 northumbriaData0.plot(kind="hist", y="week", ax=ax0)
Unused variable 'fig'
434 clevelandAgeRange = (
435 clevelandDataset.groupby(["outcome", "age_range"]).sum().unstack()
436 )
437 fig, (ax0, ax1) = plt.subplots(nrows=1, ncols=2, sharex=True, figsize=(10, 10))438 clevelandAgeRange.plot(kind="bar", y="months", ax=ax0)
439 northumbriaAgeRange.plot(kind="bar", y="months", ax=ax1)
440 ax0.set(title="Cleveland result", xlabel="outcome", ylabel="time")
Unused variable 'fig'
354 totalStocktononTeesTable = stocktonOnTeesTable.sum(axis=1, numeric_only=True)
355 stocktonOnTeesTable["TotalRollingRate"] = totalStocktononTeesTable
356 # create 3 plots to display results
357 fig, (ax0, ax1, ax2) = plt.subplots(358 nrows=1, ncols=3, sharey=True, figsize=(10, 66)
359 )
360 darlingtonTable.plot(kind="hist", y="TotalRollingRate", x="Week", ax=ax0)
Unused variable 'valueNull'
286 covidData = pd.read_csv(file7, index_col=0, parse_dates=["date"])
287
288 covidData.drop_duplicates()
289 valueNull = covidData.isnull().sum()290 cumulativeSumTable = covidData.drop(
291 [
292 "newCasesBySpecimenDate-0_4",
Unused variable 'fig'
219 axis=1, numeric_only=True
220 )
221 redcarAndClevelandTable["TotalRollingRate"] = totalRedcarAndClevelandTable
222 fig, (ax0, ax1, ax2) = plt.subplots(223 nrows=1, ncols=3, sharey=True, figsize=(10, 66)
224 )
225 hattlepoolTable.plot(kind="barh", y="TotalRollingRate", x="Week", ax=ax0)
Unused variable 'stockton_on_teesTable'
210 hattlepoolTable = rollingRateTable[0:231]
211 middlesBroughTable = rollingRateTable[232:462]
212 redcarAndClevelandTable = rollingRateTable[463:699]
213 stockton_on_teesTable = rollingRateTable[701:900]214 total_rate = hattlepoolTable.sum(axis=1, numeric_only=True)
215 hattlepoolTable["TotalRollingRate"] = total_rate
216 totalRateMiddlesbrough = middlesBroughTable.sum(axis=1, numeric_only=True)
Unused variable 'valueNull'
154 file2 = open_file()
155 covidDataa = pd.read_csv(file2, index_col=0, parse_dates=["date"])
156 covidDataa.drop_duplicates()
157 valueNull = covidDataa.isnull().sum()158
159 rollingRateTable = covidDataa.drop(
160 [
Description
An unused variable takes up space in the code, and can lead to confusion, and it should be removed. If this variable is necessary, name the variable _
to indicate that it will be unused, or start the name with unused
or _unused
.
Bad practice
def update():
for i in range(10): # Usused variable `i`
time.sleep(0.01)
display_result()
Preferred:
def update():
for _ in range(10):
time.sleep(0.01)
display_result()