Deploying a machine learning model using Flask

| | | | | | | | | | |

👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!

To use them to predict new data, we have to deploy it over the Internet so that the outside world can use it. In this article, we will talk about how we trained a machine learning model, built a web application on it using Flask.

We have to install a lot of necessary libraries that will be used in this model. Use pip to install all libraries.

 pip install pandas pip install numpy pip install sklearn 

Decision tree —
Decision tree — it is a well-known supervised machine learning algorithm because it is easy to use, elastic and flexible. I have implemented the algorithm on an adult dataset from the UCI machine learning repository.

Retrieve the data —
You can retrieve the dataset by this link .

Getting the dataset is not the end. We have to preprocess the data, which means we need to clear the dataset. Dataset cleansing involves various types of processes such as removing missing values, filling in NA values, etc.

# import dataset

import pandas

import numpy

from sklearn import preprocessing

df = pandas.read_csv ( ’adult.csv’ )

df.head ()


Dataset preprocessing —
It consists of 14 attributes and a class label indicating whether an individual’s income is less or more 50 thousand a year. These attributes range from a person’s age, working class label, to relationship status, and the race the person belongs to. Information about all attributes can be found here.

First, we find and remove all missing values ‚Äã‚Äãfrom the data. We have replaced the missing values ‚Äã‚Äãwith the mode value in this column. There are many other ways to replace missing values, but this seemed to be the best for this dataset type.

df = df.drop ([ ’fnlwgt’ , ’educational-num’ ], axis = 1 )

col_names = df.columns

for c in col_names:

df = df.replace ( "? " , numpy. NaN)

df = df. apply ( lambda x: x.fillna (x.value_counts (). index [ 0 ]))

The machine learning algorithm cannot handle categorical data values. It can only handle numeric values.
To fit the data into the forecasting model, we need to convert the categorical values ‚Äã‚Äãto numeric values. Before doing this, we will assess whether any transformations are needed on the categorical columns.

Discreteness — is a common way to make categorical data more accurate and meaningful. We have applied discretization to the marital_status column where they are narrowed down to only married or unmarried values. Later, we will apply the label encoder on the remaining data columns. Also, there are two redundant columns {& # 39; education & # 39 ;, & # 39; educational-num & # 39;} , so we removed one of them.

df.replace ([ ’Divorced’ , ’Married-AF-spouse’ ,

’Married-civ-spouse’ , ’ Married-spouse-absent’ ,

’Never-married’ , ’Separated’ , ’Widowed’ ],

[ ’divorced’ , ’married’ , ’ married’ , ’married’ ,

’not married’ , ’ not married’ , ’not married’ ], inplace = True )

category_col = [ ’workclass’ , ’ race’ , ’education’ , ’marital-status’ , ’occupation’ ,

’relationship’ , ’ gender’ , ’native-country’ , ’ income’ ]

labelEncoder = preprocessing.LabelEncoder ()

mapping_dict = {}

for col in category_col:

df [col] = labelEncoder. fit_transform (df [col])

le_name_mapping = dict ( zip (labelEncoder.classes_,

labelEncoder. transform (labelEncoder.classes_)))

mapping_dict [col] = le_name_mapping

print (mapping_dict)


{’workclass’: {’?’: 0, ’Federal-gov’: 1, ’Local-gov’: 2, ’Never-worked’: 3, ’Private’: 4, ’Self-emp-inc’: 5, ’Self-emp-not-inc’: 6, ’State-gov ’: 7,’ Without-pay ’: 8},’ ra ce ’: {’ Amer-Indian-Eskimo ’: 0,’ Asian-Pac-Islander ’: 1,’ Black ’: 2,’ Other ’: 3,’ White ’: 4},’ education ’: {’ 10th ’: 0,’ 11th ’: 1,’ 12th ’: 2,’ 1st-4th ’: 3,’ 5th-6th ’: 4,’ 7th-8th ’: 5,’ 9th ’: 6,’ Assoc-acdm ’: 7,’ Assoc-voc ’: 8,’ Bachelors’: 9, ’Doctorate’: 10, ’HS-grad’: 11, ’Masters’: 12,’ Preschool ’: 13,’ Prof-school ’: 14, ’Some-college’: 15}, ’marital-status’: {’ Divorced ’: 0,’ Married-AF-spouse ’: 1,’ Married-civ-spouse ’: 2,’ Married-spouse-absent ’: 3,’ Never-married ’: 4,’ Separated ’: 5,’ Widowed ’: 6},’ occupation ’: {’? ’: 0,’ Adm-clerical ’: 1,’ Armed-Forces’: 2, ’Craft-repair’: 3, ’Exec-managerial’: 4, ’Farming-fishing’: 5, ’Handlers-cleaners’: 6, ’Machine-op-inspct’: 7, ’Other-service’: 8, ’Priv-house-serv’: 9, ’Prof-specialty’: 10, ’Protective-serv’: 11, ’Sales’: 12, ’Tech-support’: 13, ’Transport-moving’: 14} , ’relationship’: {’Husband’: 0, ’Not-in-family’: 1, ’Other-relative’: 2, ’Own-child’: 3, ’Unmarried’: 4, ’Wife’: 5} , ’gender’: { ’Female’: 0, ’Male’: 1}, ’native-country’: {’?’: 0, ’Cambodia’: 1, ’Canada’: 2, ’China’: 3, ’Columbia’: 4, ’Cuba’: 5, ’Dominican-Republic’: 6, ’Ecuador’: 7, ’El-Salvador’: 8, ’England’: 9, ’France’: 10, ’Germany’: 11, ’Greece’: 12, ’Guatemala’: 13, ’Haiti’: 14, ’Holand-Netherlands’: 15, ’Honduras’: 16, ’Hong’: 17, ’Hungary’: 18, ’India’: 19, ’Iran’: 20, ’Ireland’: 21, ’Italy’: 22, ’Jamaica’: 23, ’Japan’: 24, ’Laos’: 25,’ Mexico ’: 26,’ Nicaragua ’: 27,’ Outlying-US (Guam -USVI-etc) ’: 28,’ Peru ’: 29,’ Philippines’: 30, ’Poland’: 31, ’Portugal’: 32, ’Puerto-Rico’: 33, ’Scotland’: 34, ’South’ : 35, ’Taiwan’: 36, ’Thailand’: 37, ’Trinadad & amp; Tobago’: 38, ’United-States’: 39, ’Vietnam’: 40, ’Yugos lavia’: 41}, ’income’: { ’50K’: 1}}

Fitting the model —
After preprocessing, the data is ready to be transferred to machine learning algorithm. Then we slice up the data by stripping the labels with the attributes. We have now split the dataset into two halves, one for training and one for testing. This is achieved with the train_test_split () sklearn function.

from sklearn. model_selection import train_test_split

from sklearn.tree import DecisionTreeClassifier

from sklearn.metrics import accuracy_score

X = df.values ‚Äã‚Äã[:, 0 : 12 ]

Y = df.values ‚Äã‚Äã[:, 12 ]

Here we have used the decision tree classifier as the prediction model. We have provided the training part with data for training the model.
Upon completion of training, we validate the accuracy of the model by providing some of the data to test the model.
Thanks to this, we achieve an accuracy of approximately 84%. Now, in order to use this model with new unknown data, we need to save the model so that we can predict values ‚Äã‚Äãlater. To do this, we use Pickle in Python, which is a powerful algorithm for serializing and deserializing the structure of Python objects.

X_train, X_test, y_train , y_test = train_test_split (

X, Y, test_size = 0.3 , random_state = 100 )

dt_clf_gini = DecisionTreeClassifier (criterion = "gini" ,

random_state = 100 ,

max_depth = 5 ,

min_samples_leaf = 5 ) (X_train, y_train)

y_pred_gini = dt_clf_gini.predict (X_test)

print ( "Desicion Tree using Gini Index Accuracy is" ,

accuracy_score (y_test, y_pred_gini) * 100 )


 Desicion Tree using Gini Index Accuracy is 83.13031016480704 

Now, infusion —
Flask — it is a Python-based micro-framework used for developing small websites. Flask is very easy to build Restful APIs using Python. At this point, we have developed a model.pkl model that can predict the data class based on various data attributes. Class label — Salary & gt; = 50K or & lt; 50K .
Now we will design a web application in which the user will enter all the attribute values ‚Äã‚Äãand the data will be received by the model, based on the training given to the model, the model will predict what the salary of the person whose data has been fed should be.

HTML Form —
To predict income from various attributes, we first need to collect data (new attribute values) and then use the decision tree model we built above to predict whether the income will be more than 50K or less. Therefore, to collect data, we create an HTML form that will contain all the different options to select from each attribute. Here we have created a simple form using only HTML. If you want to make the form more interactive, you can do so.

& lt; html & gt;

& lt; body & gt;

& lt; h3 & gt; Income Prediction Form & lt; / h3 & gt;

& lt; div & gt;

& lt; form action = "/ result" method = "POST" & gt;

& lt; label for = "age" & gt; Age & lt; / label & gt;

& lt; input type = "text" id = "age" name = "age" & gt;

& lt; br & gt;

& lt; label for = "w_class" & gt; Working Class & lt; / label & gt;

& lt; select id = "w_class" name = "w_class" & gt;

& lt; option value = "0" & gt; Federal-gov & lt; / option & gt;

& lt; option value = "1" & gt; Local-gov & lt; / option & gt;

& lt; option value = "2" & gt; Never-worked & lt; / option & gt;

& lt; option value = "3" & gt; Private & lt; / option & gt;

& lt; option value = "4" & gt; Self-emp-inc & lt; / option & gt;

& lt; option value = "5" & gt; Self-emp-not-inc & lt; / option & gt;

& lt; option value = "6" & gt; State-gov & lt; / option & gt;

& lt; option value = "7" & gt; Without-pay & lt; / option & gt;

& lt; / select & gt;

& lt; br & gt;

& lt; label for = "edu" & gt; Education & lt; / label & gt;

& lt; select id = "edu" name = "edu" & gt;

& lt; option value = "0" & gt; 10th & lt; / option & gt;

& lt; option value = "1" & gt; 11th & lt; / option & gt;

& lt; option value = "2" & gt; 12th & lt; / option & gt;

& lt; option value = "3" & gt; 1st-4th & lt; / option & gt;

& lt; option value = "4" & gt; 5th-6th & lt; / option & gt;

& lt; option value = "5" & gt; 7th-8th & lt; / option & gt;

& lt; option value = "6" & gt; 9th & lt; / option & gt;

& lt; option value = "7" & gt; Assoc-acdm & lt; / option & gt;

& lt; option value = "8" & gt; Assoc-voc & lt; / option & gt;

& lt; option value = "9" & gt; Bachelors & lt; / option & gt;

& lt; option value = "10" & gt; Doctorate & lt; / option & gt;

& lt; option value = "11" & gt; HS-grad & lt; / option & gt;

& lt; option value = "12" & gt; Masters & lt; / option & gt;

& lt; option value = "13" & gt; Preschool & lt; / option & gt;

& lt; option value = "14" & gt; Prof-school & lt; / option & gt;

& lt; option value = "15" & gt; 16 - Some-college & lt; / option & gt;

& lt; / select & gt;

& lt; br & gt;

& lt; label for = "martial_stat" & gt; Marital Status & lt; / label & gt;

& lt; select id = "martial_stat" name = "martial_stat" & gt;

& lt; option value = "0" & gt; divorced & lt; / option & gt;

& lt; option value = "1" & gt; married & lt; / option & gt;

& lt; option value = "2" & gt; not married & lt; / option & gt;

& lt; / select & gt;

& lt; br & gt;

code class = "plain"> & gt; divorced & lt; / option & gt;

& lt; option value = "1"

👻 Read also: what is the best laptop for engineering students?

Deploying a machine learning model using Flask __del__: Questions

How can I make a time delay in Python?

5 answers

I would like to know how to put a time delay in a Python script.


Answer #1

import time
time.sleep(5)   # Delays for 5 seconds. You can also use a float value.

Here is another example where something is run approximately once a minute:

import time
while True:
    print("This prints once a minute.")
    time.sleep(60) # Delay for 1 minute (60 seconds).


Answer #2

You can use the sleep() function in the time module. It can take a float argument for sub-second resolution.

from time import sleep
sleep(0.1) # Time in seconds

Deploying a machine learning model using Flask __del__: Questions

How to delete a file or folder in Python?

5 answers

How do I delete a file or folder in Python?


Answer #1

Path objects from the Python 3.4+ pathlib module also expose these instance methods:

How do I merge two dictionaries in a single expression (taking union of dictionaries)?

5 answers

Carl Meyer By Carl Meyer

I have two Python dictionaries, and I want to write a single expression that returns these two dictionaries, merged (i.e. taking the union). The update() method would be what I need, if it returned its result instead of modifying a dictionary in-place.

>>> x = {"a": 1, "b": 2}
>>> y = {"b": 10, "c": 11}
>>> z = x.update(y)
>>> print(z)
>>> x
{"a": 1, "b": 10, "c": 11}

How can I get that final merged dictionary in z, not x?

(To be extra-clear, the last-one-wins conflict-handling of dict.update() is what I"m looking for as well.)


Answer #1

How can I merge two Python dictionaries in a single expression?

For dictionaries x and y, z becomes a shallowly-merged dictionary with values from y replacing those from x.

  • In Python 3.9.0 or greater (released 17 October 2020): PEP-584, discussed here, was implemented and provides the simplest method:

    z = x | y          # NOTE: 3.9+ ONLY
  • In Python 3.5 or greater:

    z = {**x, **y}
  • In Python 2, (or 3.4 or lower) write a function:

    def merge_two_dicts(x, y):
        z = x.copy()   # start with keys and values of x
        z.update(y)    # modifies z with keys and values of y
        return z

    and now:

    z = merge_two_dicts(x, y)


Say you have two dictionaries and you want to merge them into a new dictionary without altering the original dictionaries:

x = {"a": 1, "b": 2}
y = {"b": 3, "c": 4}

The desired result is to get a new dictionary (z) with the values merged, and the second dictionary"s values overwriting those from the first.

>>> z
{"a": 1, "b": 3, "c": 4}

A new syntax for this, proposed in PEP 448 and available as of Python 3.5, is

z = {**x, **y}

And it is indeed a single expression.

Note that we can merge in with literal notation as well:

z = {**x, "foo": 1, "bar": 2, **y}

and now:

>>> z
{"a": 1, "b": 3, "foo": 1, "bar": 2, "c": 4}

It is now showing as implemented in the release schedule for 3.5, PEP 478, and it has now made its way into the What"s New in Python 3.5 document.

However, since many organizations are still on Python 2, you may wish to do this in a backward-compatible way. The classically Pythonic way, available in Python 2 and Python 3.0-3.4, is to do this as a two-step process:

z = x.copy()
z.update(y) # which returns None since it mutates z

In both approaches, y will come second and its values will replace x"s values, thus b will point to 3 in our final result.

Not yet on Python 3.5, but want a single expression

If you are not yet on Python 3.5 or need to write backward-compatible code, and you want this in a single expression, the most performant while the correct approach is to put it in a function:

def merge_two_dicts(x, y):
    """Given two dictionaries, merge them into a new dict as a shallow copy."""
    z = x.copy()
    return z

and then you have a single expression:

z = merge_two_dicts(x, y)

You can also make a function to merge an arbitrary number of dictionaries, from zero to a very large number:

def merge_dicts(*dict_args):
    Given any number of dictionaries, shallow copy and merge into a new dict,
    precedence goes to key-value pairs in latter dictionaries.
    result = {}
    for dictionary in dict_args:
    return result

This function will work in Python 2 and 3 for all dictionaries. e.g. given dictionaries a to g:

z = merge_dicts(a, b, c, d, e, f, g) 

and key-value pairs in g will take precedence over dictionaries a to f, and so on.

Critiques of Other Answers

Don"t use what you see in the formerly accepted answer:

z = dict(x.items() + y.items())

In Python 2, you create two lists in memory for each dict, create a third list in memory with length equal to the length of the first two put together, and then discard all three lists to create the dict. In Python 3, this will fail because you"re adding two dict_items objects together, not two lists -

>>> c = dict(a.items() + b.items())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: "dict_items" and "dict_items"

and you would have to explicitly create them as lists, e.g. z = dict(list(x.items()) + list(y.items())). This is a waste of resources and computation power.

Similarly, taking the union of items() in Python 3 (viewitems() in Python 2.7) will also fail when values are unhashable objects (like lists, for example). Even if your values are hashable, since sets are semantically unordered, the behavior is undefined in regards to precedence. So don"t do this:

>>> c = dict(a.items() | b.items())

This example demonstrates what happens when values are unhashable:

>>> x = {"a": []}
>>> y = {"b": []}
>>> dict(x.items() | y.items())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: "list"

Here"s an example where y should have precedence, but instead the value from x is retained due to the arbitrary order of sets:

>>> x = {"a": 2}
>>> y = {"a": 1}
>>> dict(x.items() | y.items())
{"a": 2}

Another hack you should not use:

z = dict(x, **y)

This uses the dict constructor and is very fast and memory-efficient (even slightly more so than our two-step process) but unless you know precisely what is happening here (that is, the second dict is being passed as keyword arguments to the dict constructor), it"s difficult to read, it"s not the intended usage, and so it is not Pythonic.

Here"s an example of the usage being remediated in django.

Dictionaries are intended to take hashable keys (e.g. frozensets or tuples), but this method fails in Python 3 when keys are not strings.

>>> c = dict(a, **b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: keyword arguments must be strings

From the mailing list, Guido van Rossum, the creator of the language, wrote:

I am fine with declaring dict({}, **{1:3}) illegal, since after all it is abuse of the ** mechanism.


Apparently dict(x, **y) is going around as "cool hack" for "call x.update(y) and return x". Personally, I find it more despicable than cool.

It is my understanding (as well as the understanding of the creator of the language) that the intended usage for dict(**y) is for creating dictionaries for readability purposes, e.g.:

dict(a=1, b=10, c=11)

instead of

{"a": 1, "b": 10, "c": 11}

Response to comments

Despite what Guido says, dict(x, **y) is in line with the dict specification, which btw. works for both Python 2 and 3. The fact that this only works for string keys is a direct consequence of how keyword parameters work and not a short-coming of dict. Nor is using the ** operator in this place an abuse of the mechanism, in fact, ** was designed precisely to pass dictionaries as keywords.

Again, it doesn"t work for 3 when keys are not strings. The implicit calling contract is that namespaces take ordinary dictionaries, while users must only pass keyword arguments that are strings. All other callables enforced it. dict broke this consistency in Python 2:

>>> foo(**{("a", "b"): None})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() keywords must be strings
>>> dict(**{("a", "b"): None})
{("a", "b"): None}

This inconsistency was bad given other implementations of Python (PyPy, Jython, IronPython). Thus it was fixed in Python 3, as this usage could be a breaking change.

I submit to you that it is malicious incompetence to intentionally write code that only works in one version of a language or that only works given certain arbitrary constraints.

More comments:

dict(x.items() + y.items()) is still the most readable solution for Python 2. Readability counts.

My response: merge_two_dicts(x, y) actually seems much clearer to me, if we"re actually concerned about readability. And it is not forward compatible, as Python 2 is increasingly deprecated.

{**x, **y} does not seem to handle nested dictionaries. the contents of nested keys are simply overwritten, not merged [...] I ended up being burnt by these answers that do not merge recursively and I was surprised no one mentioned it. In my interpretation of the word "merging" these answers describe "updating one dict with another", and not merging.

Yes. I must refer you back to the question, which is asking for a shallow merge of two dictionaries, with the first"s values being overwritten by the second"s - in a single expression.

Assuming two dictionaries of dictionaries, one might recursively merge them in a single function, but you should be careful not to modify the dictionaries from either source, and the surest way to avoid that is to make a copy when assigning values. As keys must be hashable and are usually therefore immutable, it is pointless to copy them:

from copy import deepcopy

def dict_of_dicts_merge(x, y):
    z = {}
    overlapping_keys = x.keys() & y.keys()
    for key in overlapping_keys:
        z[key] = dict_of_dicts_merge(x[key], y[key])
    for key in x.keys() - overlapping_keys:
        z[key] = deepcopy(x[key])
    for key in y.keys() - overlapping_keys:
        z[key] = deepcopy(y[key])
    return z


>>> x = {"a":{1:{}}, "b": {2:{}}}
>>> y = {"b":{10:{}}, "c": {11:{}}}
>>> dict_of_dicts_merge(x, y)
{"b": {2: {}, 10: {}}, "a": {1: {}}, "c": {11: {}}}

Coming up with contingencies for other value types is far beyond the scope of this question, so I will point you at my answer to the canonical question on a "Dictionaries of dictionaries merge".

Less Performant But Correct Ad-hocs

These approaches are less performant, but they will provide correct behavior. They will be much less performant than copy and update or the new unpacking because they iterate through each key-value pair at a higher level of abstraction, but they do respect the order of precedence (latter dictionaries have precedence)

You can also chain the dictionaries manually inside a dict comprehension:

{k: v for d in dicts for k, v in d.items()} # iteritems in Python 2.7

or in Python 2.6 (and perhaps as early as 2.4 when generator expressions were introduced):

dict((k, v) for d in dicts for k, v in d.items()) # iteritems in Python 2

itertools.chain will chain the iterators over the key-value pairs in the correct order:

from itertools import chain
z = dict(chain(x.items(), y.items())) # iteritems in Python 2

Performance Analysis

I"m only going to do the performance analysis of the usages known to behave correctly. (Self-contained so you can copy and paste yourself.)

from timeit import repeat
from itertools import chain

x = dict.fromkeys("abcdefg")
y = dict.fromkeys("efghijk")

def merge_two_dicts(x, y):
    z = x.copy()
    return z

min(repeat(lambda: {**x, **y}))
min(repeat(lambda: merge_two_dicts(x, y)))
min(repeat(lambda: {k: v for d in (x, y) for k, v in d.items()}))
min(repeat(lambda: dict(chain(x.items(), y.items()))))
min(repeat(lambda: dict(item for d in (x, y) for item in d.items())))

In Python 3.8.1, NixOS:

>>> min(repeat(lambda: {**x, **y}))
>>> min(repeat(lambda: merge_two_dicts(x, y)))
>>> min(repeat(lambda: {k: v for d in (x, y) for k, v in d.items()}))
>>> min(repeat(lambda: dict(chain(x.items(), y.items()))))
>>> min(repeat(lambda: dict(item for d in (x, y) for item in d.items())))
$ uname -a
Linux nixos 4.19.113 #1-NixOS SMP Wed Mar 25 07:06:15 UTC 2020 x86_64 GNU/Linux

Resources on Dictionaries


Answer #2

In your case, what you can do is:

z = dict(list(x.items()) + list(y.items()))

This will, as you want it, put the final dict in z, and make the value for key b be properly overridden by the second (y) dict"s value:

>>> x = {"a":1, "b": 2}
>>> y = {"b":10, "c": 11}
>>> z = dict(list(x.items()) + list(y.items()))
>>> z
{"a": 1, "c": 11, "b": 10}

If you use Python 2, you can even remove the list() calls. To create z:

>>> z = dict(x.items() + y.items())
>>> z
{"a": 1, "c": 11, "b": 10}

If you use Python version 3.9.0a4 or greater, then you can directly use:

x = {"a":1, "b": 2}
y = {"b":10, "c": 11}
z = x | y
{"a": 1, "c": 11, "b": 10}


Answer #3

An alternative:

z = x.copy()

We hope this article has helped you to resolve the problem. Apart from Deploying a machine learning model using Flask, check other __del__-related topics.

Want to excel in Python? See our review of the best Python online courses 2022. If you are interested in Data Science, check also how to learn programming in R.

By the way, this material is also available in other languages:

Julia Danburry

San Francisco | 2022-12-10

I was preparing for my coding interview, thanks for clarifying this - Deploying a machine learning model using Flask in Python is not the simplest one. I am just not quite sure it is the best method

Dmitry Nickolson

Abu Dhabi | 2022-12-10

open is always a bit confusing 😭 Deploying a machine learning model using Flask is not the only problem I encountered. Checked yesterday, it works!

Marie Galleotti

Munchen | 2022-12-10

Maybe there are another answers? What Deploying a machine learning model using Flask exactly means?. I am just not quite sure it is the best method


Learn programming in R: courses


Best Python online courses for 2022


Best laptop for Fortnite


Best laptop for Excel


Best laptop for Solidworks


Best laptop for Roblox


Best computer for crypto mining


Best laptop for Sims 4


Latest questions


Common xlabel/ylabel for matplotlib subplots

12 answers


How to specify multiple return types using type-hints

12 answers


Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers


Flake8: Ignore specific warning for entire file

12 answers


glob exclude pattern

12 answers


How to avoid HTTP error 429 (Too Many Requests) python

12 answers


Python CSV error: line contains NULL byte

12 answers


csv.Error: iterator should return strings, not bytes

12 answers


Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python


How to specify multiple return types using type-hints


Printing words vertically in Python


Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries


Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically