Months as axis ticks

Tough to try without your exact data, but I think you’re simply missing a call to set_major_formatter. import datetime import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates # Generate some random date-time data numdays = 500 base = datetime.datetime.today() date_list = [base – datetime.timedelta(days=x) for x in range(0, numdays)] y = … Read more

How to extract first 8 characters from a string in pandas

You are close, need indexing with str which is apply for each value of Series: data[‘Order_Date’] = data[‘Shipment ID’].str[:8] For better performance if no NaNs values: data[‘Order_Date’] = [x[:8] for x in data[‘Shipment ID’]] print (data) Shipment ID Order_Date 0 20180504-S-20000 20180504 1 20180514-S-20537 20180514 2 20180514-S-20541 20180514 3 20180514-S-20644 20180514 4 20180514-S-20644 20180514 5 … Read more

Add numpy.get_include() argument to setuptools without preinstalled numpy

First question, when is numpy needed? It is needed during the setup (i.e. when build_ext-funcionality is called) and in the installation, when the module is used. That means numpy should be in setup_requires and in install_requires. There are following alternatives to solve the issue for the setup: using PEP 517/518 (which is more straight forward … Read more

When importing tensorflow, I get the following error: No module named ‘numpy.core._multiarray_umath’

I also had the same issue. It got resloved once i upgraded the numpy from 1.15.4 to 1.16.1. If you’re using pip: pip install numpy –upgrade Numpy that came with Anaconda3 is of version 1.15.4. so i upgraded and it worked. Side note: if you’re also using scikit-image in your script, be aware that numpy … Read more

ModuleNotFoundError: No module named ‘__main__.xxxx’; ‘__main__’ is not a package

.moduleB is a relative import. Relative only works when the parent module is imported or loaded first. That means you need to have proj imported somewhere in your current runtime environment. When you are are using command python3 moduleA.py3, it is getting no chance to import parent module. You can: from proj.moduleB import moduleB OR … Read more

Failed to load resource: the server responded with a status of 429 (Too Many Requests) and 404 (Not Found) with ChromeDriver Chrome through Selenium

429 Too Many Requests The HTTP 429 Too Many Requests response status code indicates that the user has sent too many requests in a given amount of time (“rate limiting”). The response representations SHOULD include details explaining the condition, and MAY include a Retry-After header indicating how long to wait before making a new request. … Read more

Optimize Sieve of Eratosthenes Further

a slightly different approach: use a bitarray to represent the odd numbers 3,5,7,… saving some space compared to a list of booleans. this may save some space only and not help speedup… from bitarray import bitarray def index_to_number(i): return 2*i+3 def number_to_index(n): return (n-3)//2 LIMIT_NUMBER = 50 LIMIT_INDEX = number_to_index(LIMIT_NUMBER)+1 odd_primes = bitarray(LIMIT_INDEX) # index … Read more