How do I copy a file in Python?

How do I copy a file in Python? I couldn't find anything under os.

How to convert XSD to Python Class

I just want to know if there is a program that can convert an XSD file to a Python class as JAXB does for Java?

Print all day-dates between two dates

For example: from datetime import date d1 = date(2008,8,15) d2 = date(2008,9,15) I'm looking for simple code to print all dates in-between: 2008,8,15 2008,8,16 2008,8,17 ... 2008,9,14 ...

How to print +1 in Python, as +1 (with plus sign) instead of 1?

As mentioned in the title, how do I get Python to print out +1 instead of 1? score = +1 print score >> 1 I know -1 prints as -1 but how can I get positive values to print with + sign without...

How to convert string literals to strings?

I want to convert a string literal like r"r'\nasdf'" to a string ('\\nasdf' in this case). Another case: r"'\nasdf'" to '\nasdf'. I hope you get it. This is important, because I have a parser of...

How do comparison operators < and > work with a function as an operand?

Ran into this problem (in Python 2.7.5) with a little typo: def foo(): return 3 if foo > 8: launch_the_nukes() Dang it, I accidentally exploded the Moon. My understanding is that E > F is...

Max retries exceeded with URL in requests

I'm trying to get the content of App Store > Business: import requests from lxml import html page = requests.get("https://itunes.apple.com/in/genre/ios-business/id6000?mt=8") tree =...

ImportError: cannot import name check_array from sklearn.utils.validation

When I import the function check_array from module sklearn.utils.validation, it got an Import Error (ImportError: cannot import name check_array). The tab completion got check_arrays, but I'm...

Fail to install PyX using Anaconda

I'm having problems installing python modules PyX, I received the following error when using pip: $ pip install PyX Collecting PyX Could not find a version that satisfies the requirement PyX...

Why is python setup.py saying invalid command 'bdist_wheel' on Travis CI?

My Python package has a setup.py which builds fine locally on Ubuntu Trusty and on a fresh Vagrant Ubuntu Trusty VM when I provision it like this: sudo apt-get install python python-dev...

How to change the point size for regplot(), seaborn's scatter plot function (python)

I want to be able to set the point size when plotting like this: sns.regplot(y=[1,3,4,2,5], x=[range(5)], data=df, marker='o', color='red') plt.show() Do you guys know how?

FileNotFoundError while writing to a Pickle file

I'm taking all the filenames in a certain directory in a list, and would like to write this list in a pickle file. Here's the code I am using: import _pickle as pickle with...

Generate random number in range excluding some numbers

Is there a simple way in Python to generate a random number in a range excluding some subset of numbers in that range? For example, I know that you can generate a random number between 0 and 9...

Tensorflow import error: No module named 'tensorflow'

I installed TensorFlow on my Windows Python 3.5 Anaconda environment The validation was successful (with a warning) (tensorflow) C:\>python Python 3.5.3 |Intel Corporation| (default, Apr 27...

Different colors for points and line in Seaborn regplot

All examples listed in Seaborn's regplot documentation show the same color for dots and the regression line. Changing the color argument changes both. How can one set a different color for the...

Search and replace dots and commas in pandas dataframe

This is my DataFrame: d = {'col1': ['sku 1.1', 'sku 1.2', 'sku 1.3'], 'col2': ['9.876.543,21', 654, '321,01']} df = pd.DataFrame(data=d) df col1 col2 0 sku 1.1 ...

Getting links of Youtube search result

I am trying to get links of videos that appear in search result for a particular query on YouTube. I am using BeautifulSoup and requests library of Python and here is what I did: from bs4 import...

How can I scrape multiple pages using Beautiful Soup?

How can I scrape multiple pages from a website? This code is only working for the first one: import csv import requests from bs4 import BeautifulSoup import datetime filename = "azet_" +...

Logging and raising an exception

I'd like to keep a solid logging system going, but it's also necessary to raise exceptions. This code accomplishes what I'm going for, but it looks clunky and not very Pythonic. What's a better...

How can I loop a scrapy script?

Scenario: I have a scrapy script which scrapes the site. Once the required keyword is found in the scraped detail, it'll send a mail. There is a site which changes data every 30 minutes, I need to...

How to fix: Conda activation is not working?

installed Python 3.7.3 and Anaconda and tried to activate it in the Anaconda Prompt. activate %PATH% but i get the error activate does not accept more than one argument What can I do about it ?

How to get Oauth Token from Spotify

Currently I'm trying to learn how to add the liked youtube videos into a Spotify playlist using python and I'm learning from https://www.youtube.com/watch?v=7J_qcttfnJA&t=300s In 2:18 of the...

Using hash for identity on Python dataclasses

I have the following Filer entity (in the domain-driven design sense). from dataclasses import dataclass, field @dataclass class Address: street: str city: str state: str zipcode:...

How can I create code that will show prime numbers correctly in Python?

A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime...

Install Matlab engine in Anaconda Python (Windows)

I'm trying to install the matlab.engine package for anaconda spyder on windows. I have tried: cd matlabroot\extern\engines\python python setup.py install But i get the error: could not create...

norm.ppf vs norm.cdf in python's scipy.stats

so i have pasted my complete code for your reference, i want to know what's the use of ppf and cdf here? can you explain it? i did some research and found out that ppf(percent point function) is...

Swapping variables in python with a function

I need to write a program whose input is two integers and whose output is the two integers swapped. If input is: 3 8, output is 8 3. The program must define and call the following function....

How to create TF Dataset from GeoTiff files using custom map() function

I'm trying to create a TensorFlow Dataset from multichannel tiff files. The tfio.experimental.image.decode_tiff(image) from TensorFlow I/O works for 4 channels only so I tried to read it first...

Calculating angles of body skeleton in video using OpenPose

Disclaimer: This question is regarding OpenPose but the key here is actually to figure how to use the output (coordinates stored in the JSON) and not how to use OpenPose, so please consider...

How to setup NetBeans IDE for Python Development

I was using PyDev plugin in eclipse for developing python. But now I switched to NetBeans IDE 12.6 and I searched google for finding python plugins for NetBeans. I found a plugin called...