Top "Python-2.7" questions

Python 2.7 is the last major version in the 2.x series, and is no longer maintained since January 1st 2020.

How to get the latest file in a folder using python

I need to get the latest file of a folder using python. While using the code: max(files, key = os.…

python python-3.x python-2.7
Python for and if on one line

I have a issue with python. I make a simple list: >>> my_list = ["one","two","three"] I …

python python-2.7 for-loop if-statement list-comprehension
Construct pandas DataFrame from list of tuples of (row,col,values)

I have a list of tuples like data = [ ('r1', 'c1', avg11, stdev11), ('r1', 'c2', avg12, stdev12), (…

python python-2.7 pandas pivot
How to call Base Class's __init__ method from the child class?

If I have a python class as: class BaseClass(object): #code and the init function of the base class And …

python python-2.7 inheritance constructor
Python: OSError: [Errno 2] No such file or directory: ''

I have a 100 lines, 3 years old python scraper that now bug. Starting lines are: import urllib, re, os, sys, time # …

python python-2.7 python-module
How can I copy a Python string?

I do this: a = 'hello' And now I just want an independent copy of a: import copy b = str(a) …

python string python-2.7
How do I get a decimal value when using the division operator in Python?

For example, the standard division symbol '/' rounds to zero: >>> 4 / 100 0 However, I want it to return 0.04. …

python python-2.7 math syntax operators
TypeError: cannot perform reduce with flexible type

I have been using the scikit-learn library. I'm trying to use the Gaussian Naive Bayes Module under the scikit-learn library …

python python-2.7 scikit-learn
Python - Get Yesterday's date as a string in YYYY-MM-DD format

As an input to an API request I need to get yesterday's date as a string in the format YYYY-MM-DD. …

python python-2.7 python-3.x date datetime
What is Python buffer type for?

There is a buffer type in python, but I don't know how can I use it. In the Python doc …

python python-2.7