Unused variable 'fig'
642 northumbriaData1 = (
643 northumbria2020Dataset.groupby(["age_range", "gender"]).std().unstack()
644 )
645 fig, (ax0, ax1) = plt.subplots(646 nrows=2, ncols=1, sharey=True, figsize=(10, 10)
647 )
648 northumbriaData0.plot(kind="barh", y="day", ax=ax0)
Unused variable 'fig'
591 .mean()
592 .unstack()
593 )
594 fig, (ax0, ax1) = plt.subplots(595 nrows=2, ncols=1, sharey=True, figsize=(30, 10)
596 )
597 northumbriaData0.plot(kind="hist", y="week", ax=ax0)
Unused variable 'fig'
435 clevelandAgeRange = (
436 clevelandDataset.groupby(["outcome", "age_range"]).sum().unstack()
437 )
438 fig, (ax0, ax1) = plt.subplots(nrows=1, ncols=2, sharex=True, figsize=(10, 10))439 clevelandAgeRange.plot(kind="bar", y="months", ax=ax0)
440 northumbriaAgeRange.plot(kind="bar", y="months", ax=ax1)
441 ax0.set(title="Cleveland result", xlabel="outcome", ylabel="time")
Unused variable 'fig'
355 totalStocktononTeesTable = stocktonOnTeesTable.sum(axis=1, numeric_only=True)
356 stocktonOnTeesTable["TotalRollingRate"] = totalStocktononTeesTable
357 # create 3 plots to display results
358 fig, (ax0, ax1, ax2) = plt.subplots(359 nrows=1, ncols=3, sharey=True, figsize=(10, 66)
360 )
361 darlingtonTable.plot(kind="hist", y="TotalRollingRate", x="Week", ax=ax0)
Unused variable 'valueNull'
287 covidData = pd.read_csv(file7, index_col=0, parse_dates=["date"])
288
289 covidData.drop_duplicates()
290 valueNull = covidData.isnull().sum()291 cumulativeSumTable = covidData.drop(
292 [
293 "newCasesBySpecimenDate-0_4",
Unused variable 'fig'
220 axis=1, numeric_only=True
221 )
222 redcarAndClevelandTable["TotalRollingRate"] = totalRedcarAndClevelandTable
223 fig, (ax0, ax1, ax2) = plt.subplots(224 nrows=1, ncols=3, sharey=True, figsize=(10, 66)
225 )
226 hattlepoolTable.plot(kind="barh", y="TotalRollingRate", x="Week", ax=ax0)
Unused variable 'stockton_on_teesTable'
211 hattlepoolTable = rollingRateTable[0:231]
212 middlesBroughTable = rollingRateTable[232:462]
213 redcarAndClevelandTable = rollingRateTable[463:699]
214 stockton_on_teesTable = rollingRateTable[701:900]215 total_rate = hattlepoolTable.sum(axis=1, numeric_only=True)
216 hattlepoolTable["TotalRollingRate"] = total_rate
217 totalRateMiddlesbrough = middlesBroughTable.sum(axis=1, numeric_only=True)
Unused variable 'valueNull'
155 file2 = open_file()
156 covidDataa = pd.read_csv(file2, index_col=0, parse_dates=["date"])
157 covidDataa.drop_duplicates()
158 valueNull = covidDataa.isnull().sum()159
160 rollingRateTable = covidDataa.drop(
161 [
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()