qid int64 46k 74.7M | question stringlengths 54 37.8k | date stringlengths 10 10 | metadata listlengths 3 3 | response_j stringlengths 17 26k | response_k stringlengths 26 26k |
|---|---|---|---|---|---|
14,938,541 | I use matplotlib to plot a scatter chart:

And label the bubble using a transparent box according to the tip at [How to annotate point on a scatter automatically placed arrow](https://stackoverflow.com/q/9074996/7758804)
Here is the code:
```
if sh... | 2013/02/18 | [
"https://Stackoverflow.com/questions/14938541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1072888/"
] | Another option using my library `adjustText`, written specially for this purpose (<https://github.com/Phlya/adjustText>).
```
from adjustText import adjust_text
np.random.seed(2016)
N = 50
scatter_data = np.random.rand(N, 3)
fig, ax = plt.subplots()
ax.scatter(scatter_data[:, 0], scatter_data[:, 1],
c=scat... | We can use plotly for this. But we can't help placing overlap correctly if there is lot of data. Instead we can zoom in and zoom out.
```
import plotly.express as px
df = px.data.tips()
df = px.data.gapminder().query("year==2007 and continent=='Americas'")
fig = px.scatter(df, x="gdpPercap", y="lifeExp", text="count... |
14,938,541 | I use matplotlib to plot a scatter chart:

And label the bubble using a transparent box according to the tip at [How to annotate point on a scatter automatically placed arrow](https://stackoverflow.com/q/9074996/7758804)
Here is the code:
```
if sh... | 2013/02/18 | [
"https://Stackoverflow.com/questions/14938541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1072888/"
] | Another option using my library `adjustText`, written specially for this purpose (<https://github.com/Phlya/adjustText>).
```
from adjustText import adjust_text
np.random.seed(2016)
N = 50
scatter_data = np.random.rand(N, 3)
fig, ax = plt.subplots()
ax.scatter(scatter_data[:, 0], scatter_data[:, 1],
c=scat... | Just created another quick solution that is also very fast: [textalloc](https://github.com/ckjellson/textalloc)
In this case you could do something like this:
```
import textalloc as ta
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(2022)
N = 30
scatter_data = np.random.rand(N, 3)*10
fig, ax = pl... |
34,314,022 | The documentation linked below seems to say that top level classes can be pickled, as well as their instances. But based on the answers to my previous [question](https://stackoverflow.com/q/34261379/3904031) it seem not to be correct. In the script I posted the pickle accepts the class object and writes a file, but thi... | 2015/12/16 | [
"https://Stackoverflow.com/questions/34314022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3904031/"
] | Make a class that is *defined at the top level of a module*:
**foo.py**:
```
class Foo(object): pass
```
Then running a separate script,
**script.py**:
```
import pickle
import foo
with open('/tmp/out.pkl', 'w') as f:
pickle.dump(foo.Foo, f)
del foo
with open('/tmp/out.pkl', 'r') as f:
cls = pickle.loa... | It's totally possible to pickle a class instance in python… while also saving the code to reconstruct the class and the instance's state. If you want to hack together a solution on top of `pickle`, or use a "trojan horse" `exec` based method here's how to do it:
[How to unpickle an object whose class exists in a diffe... |
22,734,148 | I'm trying to check if a number is a perfect square. However, i am dealing with extraordinarily large numbers so python thinks its infinity for some reason. it gets up to 1.1 X 10^154 before the code returns "Inf". Is there anyway to get around this? Here is the code, the lst variable just holds a bunch of really reall... | 2014/03/29 | [
"https://Stackoverflow.com/questions/22734148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3476226/"
] | I think that you need to take a look at the [BigFloat](https://pythonhosted.org/bigfloat/) module, e.g.:
```
import bigfloat as bf
b = bf.BigFloat('1e1000', bf.precision(21))
print bf.sqrt(b)
```
Prints `BigFloat.exact('9.9999993810013282e+499', precision=53)` | math.sqrt() converts the argument to a Python float which has a maximum value around 10^308.
You should probably look at using the [gmpy2](https://code.google.com/p/gmpy/) library. gmpy2 provide very fast multiple precision arithmetic.
If you want to check for arbitrary powers, the function `gmpy2.is_power()` will re... |
22,734,148 | I'm trying to check if a number is a perfect square. However, i am dealing with extraordinarily large numbers so python thinks its infinity for some reason. it gets up to 1.1 X 10^154 before the code returns "Inf". Is there anyway to get around this? Here is the code, the lst variable just holds a bunch of really reall... | 2014/03/29 | [
"https://Stackoverflow.com/questions/22734148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3476226/"
] | I think that you need to take a look at the [BigFloat](https://pythonhosted.org/bigfloat/) module, e.g.:
```
import bigfloat as bf
b = bf.BigFloat('1e1000', bf.precision(21))
print bf.sqrt(b)
```
Prints `BigFloat.exact('9.9999993810013282e+499', precision=53)` | Replace `math.sqrt(Decimal(i))` with `Decimal(i).sqrt()` to prevent your `Decimal`s decaying into `float`s |
22,734,148 | I'm trying to check if a number is a perfect square. However, i am dealing with extraordinarily large numbers so python thinks its infinity for some reason. it gets up to 1.1 X 10^154 before the code returns "Inf". Is there anyway to get around this? Here is the code, the lst variable just holds a bunch of really reall... | 2014/03/29 | [
"https://Stackoverflow.com/questions/22734148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3476226/"
] | I think that you need to take a look at the [BigFloat](https://pythonhosted.org/bigfloat/) module, e.g.:
```
import bigfloat as bf
b = bf.BigFloat('1e1000', bf.precision(21))
print bf.sqrt(b)
```
Prints `BigFloat.exact('9.9999993810013282e+499', precision=53)` | @casevh has the right answer -- use a library that can do math on arbitrarily large integers. Since you're looking for squares, you presumably are working with integers, and one could argue that using floating point types (including decimal.Decimal) is, in some sense, inelegant.
You definitely *shouldn't* use Python's... |
22,734,148 | I'm trying to check if a number is a perfect square. However, i am dealing with extraordinarily large numbers so python thinks its infinity for some reason. it gets up to 1.1 X 10^154 before the code returns "Inf". Is there anyway to get around this? Here is the code, the lst variable just holds a bunch of really reall... | 2014/03/29 | [
"https://Stackoverflow.com/questions/22734148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3476226/"
] | Replace `math.sqrt(Decimal(i))` with `Decimal(i).sqrt()` to prevent your `Decimal`s decaying into `float`s | math.sqrt() converts the argument to a Python float which has a maximum value around 10^308.
You should probably look at using the [gmpy2](https://code.google.com/p/gmpy/) library. gmpy2 provide very fast multiple precision arithmetic.
If you want to check for arbitrary powers, the function `gmpy2.is_power()` will re... |
22,734,148 | I'm trying to check if a number is a perfect square. However, i am dealing with extraordinarily large numbers so python thinks its infinity for some reason. it gets up to 1.1 X 10^154 before the code returns "Inf". Is there anyway to get around this? Here is the code, the lst variable just holds a bunch of really reall... | 2014/03/29 | [
"https://Stackoverflow.com/questions/22734148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3476226/"
] | Replace `math.sqrt(Decimal(i))` with `Decimal(i).sqrt()` to prevent your `Decimal`s decaying into `float`s | @casevh has the right answer -- use a library that can do math on arbitrarily large integers. Since you're looking for squares, you presumably are working with integers, and one could argue that using floating point types (including decimal.Decimal) is, in some sense, inelegant.
You definitely *shouldn't* use Python's... |
30,326,654 | I'm following this for django manage.py module
<http://docs.ansible.com/django_manage_module.html>
for e.g. one of my tasks looks like -
```
- name: Django migrate
django_manage: command=migrate
app_path={{app_path}}
settings={{django_settings}}
tags:
- django
```
this wor... | 2015/05/19 | [
"https://Stackoverflow.com/questions/30326654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4414786/"
] | From Ansible website <http://docs.ansible.com/intro_installation.html>
>
> Python 3 is a slightly different language than Python 2 and most Python programs (including Ansible) are not switching over yet. However, some Linux distributions (Gentoo, Arch) may not have a Python 2.X interpreter installed by default. On th... | Ansible is using `python` to run the django command: <https://github.com/ansible/ansible-modules-core/blob/devel/web_infrastructure/django_manage.py#L237>
Your only solution is thus to override the executable that will be run, for instance by changing your PATH:
```
- file: src=/usr/bin/python3 dest=/home/user/.local... |
30,326,654 | I'm following this for django manage.py module
<http://docs.ansible.com/django_manage_module.html>
for e.g. one of my tasks looks like -
```
- name: Django migrate
django_manage: command=migrate
app_path={{app_path}}
settings={{django_settings}}
tags:
- django
```
this wor... | 2015/05/19 | [
"https://Stackoverflow.com/questions/30326654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4414786/"
] | If you edit the shebang in the Django manage.py file to be `#!/usr/bin/env python3` then you can ensure that python 3 will always be used to run your Django app.
Tried successfully with Ansible 2.3.0 and Django 1.10.5. YMMV | Ansible is using `python` to run the django command: <https://github.com/ansible/ansible-modules-core/blob/devel/web_infrastructure/django_manage.py#L237>
Your only solution is thus to override the executable that will be run, for instance by changing your PATH:
```
- file: src=/usr/bin/python3 dest=/home/user/.local... |
25,863,769 | I have a set (or a list) of numbers {1, 2.25, 5.63, 2.12, 7.98, 4.77} and i want to find the best combination of numbers from this set/list which when added are closest to 10.
How do i accomplish that in python using an element from collection ? | 2014/09/16 | [
"https://Stackoverflow.com/questions/25863769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1578720/"
] | If the problem size permits, you can use some friends in `itertools` to quickly brute force through it:
```
s = {1, 2.25, 5.63, 2.12, 7.98, 4.77}
from itertools import combinations, chain
res = min(((comb, abs(sum(comb)-10)) for comb in chain(*[combinations(s, k) for k in range(1, len(s)+1)])), key=lambda x: x[1])[0]
... | It's an NP-Hard problem. If your data are not too big, you can just test every single solution with a code like :
```
def combination(itemList):
""" Returns all the combinations of items in the list """
def wrapped(current_pack, itemList):
if itemList == []:
return [current_pack]
el... |
62,787,056 | I created virtual environment and installed both tensorflow and tensorflow-gpu. After that I installed keras. And then I checked in my conda terminal by importing keras and I was able to import keras in it. However, using jupyter notebook if I try to import keras then it gives me below error.
```
import keras
ImportEr... | 2020/07/08 | [
"https://Stackoverflow.com/questions/62787056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13605650/"
] | Did you installed the dependencies with conda? Like this:
```
$ conda install -c conda-forge keras
$ conda install -c conda-forge tensorflow
$ conda install -c anaconda tensorflow-gpu
```
If you installed with `pip` they will not work inside your virtual env. Look at your conda dependencies list, to see if the ... | Doing below solved my issue.
So I removed all the packages that were installed via pip and intstalled packages through conda. I had environment issue and created another environment from the scratch and ran below commands.
Create virtual environment:
```
conda create -n <env_name>
```
Install tensorflow-gpu via con... |
24,112,445 | I am using Python 3.4.0 and I have Mac OSX 10.9.2. I have the following code saved as sublimePygame in Sublime Text.
```
import pygame, sys
from pygame.locals import *
pygame.init()
#set up the window
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Drawing')
# set up the colors
B... | 2014/06/09 | [
"https://Stackoverflow.com/questions/24112445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3720830/"
] | Hope this link helps for part 1. Should be able to commit and push your changes using git push heroku master.
<https://devcenter.heroku.com/articles/git#tracking-your-app-in-git>
For part 2: will scaling your dynos back to 0 work for your case?
[How to stop an app on Heroku?](https://stackoverflow.com/questions/2811... | 1. When you make a change, just push the git repository to heroku again with`git push heroku master`.
The server will automatically restart with the changed system.
2. You seem to have a misconception. You can always run your local development server regardless of what Heroku is doing (unless some other service your ap... |
24,112,445 | I am using Python 3.4.0 and I have Mac OSX 10.9.2. I have the following code saved as sublimePygame in Sublime Text.
```
import pygame, sys
from pygame.locals import *
pygame.init()
#set up the window
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Drawing')
# set up the colors
B... | 2014/06/09 | [
"https://Stackoverflow.com/questions/24112445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3720830/"
] | Assuming you are using git to manage your project, you apply changes to Heroku by pushing them. This might look something like this:
```
git push heroku master
```
This pushes the master branch of your git project to Heroku.
To "turn off" your app on Heroku, you can do two things:
```
$ heroku ps:scale web=0
```
... | Hope this link helps for part 1. Should be able to commit and push your changes using git push heroku master.
<https://devcenter.heroku.com/articles/git#tracking-your-app-in-git>
For part 2: will scaling your dynos back to 0 work for your case?
[How to stop an app on Heroku?](https://stackoverflow.com/questions/2811... |
24,112,445 | I am using Python 3.4.0 and I have Mac OSX 10.9.2. I have the following code saved as sublimePygame in Sublime Text.
```
import pygame, sys
from pygame.locals import *
pygame.init()
#set up the window
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Drawing')
# set up the colors
B... | 2014/06/09 | [
"https://Stackoverflow.com/questions/24112445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3720830/"
] | Assuming you are using git to manage your project, you apply changes to Heroku by pushing them. This might look something like this:
```
git push heroku master
```
This pushes the master branch of your git project to Heroku.
To "turn off" your app on Heroku, you can do two things:
```
$ heroku ps:scale web=0
```
... | 1. When you make a change, just push the git repository to heroku again with`git push heroku master`.
The server will automatically restart with the changed system.
2. You seem to have a misconception. You can always run your local development server regardless of what Heroku is doing (unless some other service your ap... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | I actually shared my solution to this exact issue. What I did here was create a pool of connections that you can specify the max with, and then queued query requests async through this channel. This way you can leave a certain amount of connections open, but it will queue and pool async and keep the speed you are used ... | I'm no expert in this field, but I believe that [PgBouncer](https://pgbouncer.github.io/features.html) would do the job for you, assuming you're able to use a PostgreSQL back-end (that's one detail you didn't make clear). PgBouncer is a *connection pooler*, which allows you re-use connections avoiding the overhead of c... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | You could use an IoC container to store a singleton provider for you. Essentially, instead of constructing a new connection every time, it will only construct it once (the first time `ConnectionContainer.connection_provider()` is called) and thereafter it will always return the previously constructed connection.
You'l... | I'm no expert in this field, but I believe that [PgBouncer](https://pgbouncer.github.io/features.html) would do the job for you, assuming you're able to use a PostgreSQL back-end (that's one detail you didn't make clear). PgBouncer is a *connection pooler*, which allows you re-use connections avoiding the overhead of c... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | You could use an IoC container to store a singleton provider for you. Essentially, instead of constructing a new connection every time, it will only construct it once (the first time `ConnectionContainer.connection_provider()` is called) and thereafter it will always return the previously constructed connection.
You'l... | I am just sharing my knowledge over here.
*Install the PyMySQL to use the MySql*
**For Python 2.x**
```
pip install PyMySQL
```
**For Python 3.x**
```
pip3 install PyMySQL
```
**1.** If you are open to use Django Framework then it's very easy to run the SQL query without any re-connection.
In setting.py file a... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | You could use an IoC container to store a singleton provider for you. Essentially, instead of constructing a new connection every time, it will only construct it once (the first time `ConnectionContainer.connection_provider()` is called) and thereafter it will always return the previously constructed connection.
You'l... | This is not a good idea to do such a thing synchronously in web app context. Remember that your application may needs to work in multi process/thread fashion, and you could not share connection between processes normally. So if you create a connection for your user on a process, there is no guaranty to receive query re... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | I don't see why do you need a cached connection here and why not just reconnect on every request caching user's credentials somewhere, but anyway I'll try to outline a solution that might fit your requirements.
I'd suggest to look into a more generic task first - cache something between subsequent requests your app ne... | I'm no expert in this field, but I believe that [PgBouncer](https://pgbouncer.github.io/features.html) would do the job for you, assuming you're able to use a PostgreSQL back-end (that's one detail you didn't make clear). PgBouncer is a *connection pooler*, which allows you re-use connections avoiding the overhead of c... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | You could use an IoC container to store a singleton provider for you. Essentially, instead of constructing a new connection every time, it will only construct it once (the first time `ConnectionContainer.connection_provider()` is called) and thereafter it will always return the previously constructed connection.
You'l... | I don't see why do you need a cached connection here and why not just reconnect on every request caching user's credentials somewhere, but anyway I'll try to outline a solution that might fit your requirements.
I'd suggest to look into a more generic task first - cache something between subsequent requests your app ne... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | This is not a good idea to do such a thing synchronously in web app context. Remember that your application may needs to work in multi process/thread fashion, and you could not share connection between processes normally. So if you create a connection for your user on a process, there is no guaranty to receive query re... | I am just sharing my knowledge over here.
*Install the PyMySQL to use the MySql*
**For Python 2.x**
```
pip install PyMySQL
```
**For Python 3.x**
```
pip3 install PyMySQL
```
**1.** If you are open to use Django Framework then it's very easy to run the SQL query without any re-connection.
In setting.py file a... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | I don't see why do you need a cached connection here and why not just reconnect on every request caching user's credentials somewhere, but anyway I'll try to outline a solution that might fit your requirements.
I'd suggest to look into a more generic task first - cache something between subsequent requests your app ne... | I am just sharing my knowledge over here.
*Install the PyMySQL to use the MySql*
**For Python 2.x**
```
pip install PyMySQL
```
**For Python 3.x**
```
pip3 install PyMySQL
```
**1.** If you are open to use Django Framework then it's very easy to run the SQL query without any re-connection.
In setting.py file a... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | You could use an IoC container to store a singleton provider for you. Essentially, instead of constructing a new connection every time, it will only construct it once (the first time `ConnectionContainer.connection_provider()` is called) and thereafter it will always return the previously constructed connection.
You'l... | I actually shared my solution to this exact issue. What I did here was create a pool of connections that you can specify the max with, and then queued query requests async through this channel. This way you can leave a certain amount of connections open, but it will queue and pool async and keep the speed you are used ... |
53,147,752 | I am saving a user's database connection. On the first time they enter in their credentials, I do something like the following:
```
self.conn = MySQLdb.connect (
host = 'aaa',
user = 'bbb',
passwd = 'ccc',
db = 'ddd',
charset='utf8'
)
cursor = self.conn.cursor()
cursor.execute("SET NAMES utf8")
cur... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53147752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | I actually shared my solution to this exact issue. What I did here was create a pool of connections that you can specify the max with, and then queued query requests async through this channel. This way you can leave a certain amount of connections open, but it will queue and pool async and keep the speed you are used ... | I am just sharing my knowledge over here.
*Install the PyMySQL to use the MySql*
**For Python 2.x**
```
pip install PyMySQL
```
**For Python 3.x**
```
pip3 install PyMySQL
```
**1.** If you are open to use Django Framework then it's very easy to run the SQL query without any re-connection.
In setting.py file a... |
54,494,842 | I am totally new to python and basically new to programming in general.
I have a college assignment that involves scanning through a CSV file and storing each row as a list. My file is a list of football data for the premier league season so the CSV file is structured as follows:
```
date; home; away; homegoals; awayg... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54494842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11005752/"
] | One option would be to loop through the `list` ('list1'), `filter` the 'names' column based on the 'names' vector, convert it to a single dataset while creating an identification column with `.id`, `spread` from 'long' to 'wide' and remove the 'grp' column
```
library(tidyverse)
map_df(list1, ~ .x %>%
... | A mix of base R and `dplyr`. For every list element we create a dataframe with 1 row. Using `dplyr`'s `rbind_list` row bind them together and then subset only those columns which we need using `names`.
```
library(dplyr)
rbind_list(lapply(list1, function(x)
setNames(data.frame(t(x$values)), x$names)))[names]... |
54,494,842 | I am totally new to python and basically new to programming in general.
I have a college assignment that involves scanning through a CSV file and storing each row as a list. My file is a list of football data for the premier league season so the CSV file is structured as follows:
```
date; home; away; homegoals; awayg... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54494842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11005752/"
] | One option would be to loop through the `list` ('list1'), `filter` the 'names' column based on the 'names' vector, convert it to a single dataset while creating an identification column with `.id`, `spread` from 'long' to 'wide' and remove the 'grp' column
```
library(tidyverse)
map_df(list1, ~ .x %>%
... | Using base R only
```
body <- do.call('rbind', lapply(list1, function(list.element){
element.vals <- list.element[['values']]
element.names <- list.element[['names']]
names(element.vals) <- element.names
return.vals <- element.vals[names]
if(all(is.na(return.vals))) NULL else return.vals
}))
df <- as.data.f... |
54,494,842 | I am totally new to python and basically new to programming in general.
I have a college assignment that involves scanning through a CSV file and storing each row as a list. My file is a list of football data for the premier league season so the CSV file is structured as follows:
```
date; home; away; homegoals; awayg... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54494842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11005752/"
] | One option would be to loop through the `list` ('list1'), `filter` the 'names' column based on the 'names' vector, convert it to a single dataset while creating an identification column with `.id`, `spread` from 'long' to 'wide' and remove the 'grp' column
```
library(tidyverse)
map_df(list1, ~ .x %>%
... | In base R
```
t(sapply(list1, function(x) setNames(x$values, names)[match(names, x$names)]))
# a b c
# [1,] 25 13 11
# [2,] 12 10 NA
``` |
54,494,842 | I am totally new to python and basically new to programming in general.
I have a college assignment that involves scanning through a CSV file and storing each row as a list. My file is a list of football data for the premier league season so the CSV file is structured as follows:
```
date; home; away; homegoals; awayg... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54494842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11005752/"
] | One option would be to loop through the `list` ('list1'), `filter` the 'names' column based on the 'names' vector, convert it to a single dataset while creating an identification column with `.id`, `spread` from 'long' to 'wide' and remove the 'grp' column
```
library(tidyverse)
map_df(list1, ~ .x %>%
... | For the sake of completeness, here is a [data.table](/questions/tagged/data.table "show questions tagged 'data.table'") approach using `dcast()` and `rowid()`:
```
library(data.table)
nam <- names1 # avoid name conflict with column name
rbindlist(list1)[names1 %in% nam, dcast(.SD, rowid(names1) ~ names1)][, names1 :... |
54,494,842 | I am totally new to python and basically new to programming in general.
I have a college assignment that involves scanning through a CSV file and storing each row as a list. My file is a list of football data for the premier league season so the CSV file is structured as follows:
```
date; home; away; homegoals; awayg... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54494842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11005752/"
] | A mix of base R and `dplyr`. For every list element we create a dataframe with 1 row. Using `dplyr`'s `rbind_list` row bind them together and then subset only those columns which we need using `names`.
```
library(dplyr)
rbind_list(lapply(list1, function(x)
setNames(data.frame(t(x$values)), x$names)))[names]... | For the sake of completeness, here is a [data.table](/questions/tagged/data.table "show questions tagged 'data.table'") approach using `dcast()` and `rowid()`:
```
library(data.table)
nam <- names1 # avoid name conflict with column name
rbindlist(list1)[names1 %in% nam, dcast(.SD, rowid(names1) ~ names1)][, names1 :... |
54,494,842 | I am totally new to python and basically new to programming in general.
I have a college assignment that involves scanning through a CSV file and storing each row as a list. My file is a list of football data for the premier league season so the CSV file is structured as follows:
```
date; home; away; homegoals; awayg... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54494842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11005752/"
] | Using base R only
```
body <- do.call('rbind', lapply(list1, function(list.element){
element.vals <- list.element[['values']]
element.names <- list.element[['names']]
names(element.vals) <- element.names
return.vals <- element.vals[names]
if(all(is.na(return.vals))) NULL else return.vals
}))
df <- as.data.f... | For the sake of completeness, here is a [data.table](/questions/tagged/data.table "show questions tagged 'data.table'") approach using `dcast()` and `rowid()`:
```
library(data.table)
nam <- names1 # avoid name conflict with column name
rbindlist(list1)[names1 %in% nam, dcast(.SD, rowid(names1) ~ names1)][, names1 :... |
54,494,842 | I am totally new to python and basically new to programming in general.
I have a college assignment that involves scanning through a CSV file and storing each row as a list. My file is a list of football data for the premier league season so the CSV file is structured as follows:
```
date; home; away; homegoals; awayg... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54494842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11005752/"
] | In base R
```
t(sapply(list1, function(x) setNames(x$values, names)[match(names, x$names)]))
# a b c
# [1,] 25 13 11
# [2,] 12 10 NA
``` | For the sake of completeness, here is a [data.table](/questions/tagged/data.table "show questions tagged 'data.table'") approach using `dcast()` and `rowid()`:
```
library(data.table)
nam <- names1 # avoid name conflict with column name
rbindlist(list1)[names1 %in% nam, dcast(.SD, rowid(names1) ~ names1)][, names1 :... |
70,075,290 | I am try update a lambda by zappa, I created virtualenv and active virtualenv and install libraries, but in the moment run zappa update enviroment, I have this problem:
How can i fix this :(
```
zappa update qa
(pip 18.1 (/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages), Requirement.pars... | 2021/11/23 | [
"https://Stackoverflow.com/questions/70075290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16488584/"
] | You should wait for function code update to complete before proceeding with update of function configuration. Inserting the following shell script between the steps can keep the process waiting:
```
STATE=$(aws lambda get-function --function-name "$FN_NAME" --query 'Configuration.LastUpdateStatus' --output text)
while... | Add to your zappa\_settings.json:
```
"lambda_description": "aws:states:opt-out"
```
[Zappa issue about it](https://github.com/zappa/Zappa/issues/1041) |
70,075,290 | I am try update a lambda by zappa, I created virtualenv and active virtualenv and install libraries, but in the moment run zappa update enviroment, I have this problem:
How can i fix this :(
```
zappa update qa
(pip 18.1 (/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages), Requirement.pars... | 2021/11/23 | [
"https://Stackoverflow.com/questions/70075290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16488584/"
] | I would add a more sophisticated solution what mentioned LiriB earlier. Use the aws lambda cli which has the function-updated command ([documentation](https://docs.aws.amazon.com/cli/latest/reference/lambda/wait/function-updated.html)).
Example:
`aws lambda wait function-updated --function-name "$FN_NAME"`
This comma... | Add to your zappa\_settings.json:
```
"lambda_description": "aws:states:opt-out"
```
[Zappa issue about it](https://github.com/zappa/Zappa/issues/1041) |
70,075,290 | I am try update a lambda by zappa, I created virtualenv and active virtualenv and install libraries, but in the moment run zappa update enviroment, I have this problem:
How can i fix this :(
```
zappa update qa
(pip 18.1 (/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages), Requirement.pars... | 2021/11/23 | [
"https://Stackoverflow.com/questions/70075290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16488584/"
] | I would add a more sophisticated solution what mentioned LiriB earlier. Use the aws lambda cli which has the function-updated command ([documentation](https://docs.aws.amazon.com/cli/latest/reference/lambda/wait/function-updated.html)).
Example:
`aws lambda wait function-updated --function-name "$FN_NAME"`
This comma... | You should wait for function code update to complete before proceeding with update of function configuration. Inserting the following shell script between the steps can keep the process waiting:
```
STATE=$(aws lambda get-function --function-name "$FN_NAME" --query 'Configuration.LastUpdateStatus' --output text)
while... |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | This may be too roundabout for you, but you could use the %save magic function to save the lines in question and then copy them from the save file. | I tend to keep an open gvim window for this kind of things. Paste your class definition as is and then do something like:
```
:%s/^.*\.://
``` |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | One of the cool features of `ipython` is [session logging](http://ipython.org/ipython-doc/rel-1.1.0/interactive/reference.html#session-logging-and-restoring). If you enable it, the code you input in your session is logged to a file. It's very useful, I use it all the time.
To make things even niftier for me, I have a ... | This may be too roundabout for you, but you could use the %save magic function to save the lines in question and then copy them from the save file. |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | How about using `%hist n` to print line `n` (or a range of lines) without prompts (including line continuations), and doing your copy from that? (Simply scrolling back to that line is nearly as good).
```
In [1]: def foo():
...: return 1+2
...:
In [6]: %history 1
def foo():
return 1+2
``` | This may be too roundabout for you, but you could use the %save magic function to save the lines in question and then copy them from the save file. |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | This QTconsole copy regression has been fixed, see <https://github.com/ipython/ipython/issues/3206> - I can confirm that the desired behavior is again present in the QtConsole in the Canopy 1.2 GUI and, I suspect, in the ipython egg installable by free users from the Enthought egg repo. | This may be too roundabout for you, but you could use the %save magic function to save the lines in question and then copy them from the save file. |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | One of the cool features of `ipython` is [session logging](http://ipython.org/ipython-doc/rel-1.1.0/interactive/reference.html#session-logging-and-restoring). If you enable it, the code you input in your session is logged to a file. It's very useful, I use it all the time.
To make things even niftier for me, I have a ... | I tend to keep an open gvim window for this kind of things. Paste your class definition as is and then do something like:
```
:%s/^.*\.://
``` |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | How about using `%hist n` to print line `n` (or a range of lines) without prompts (including line continuations), and doing your copy from that? (Simply scrolling back to that line is nearly as good).
```
In [1]: def foo():
...: return 1+2
...:
In [6]: %history 1
def foo():
return 1+2
``` | I tend to keep an open gvim window for this kind of things. Paste your class definition as is and then do something like:
```
:%s/^.*\.://
``` |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | This QTconsole copy regression has been fixed, see <https://github.com/ipython/ipython/issues/3206> - I can confirm that the desired behavior is again present in the QtConsole in the Canopy 1.2 GUI and, I suspect, in the ipython egg installable by free users from the Enthought egg repo. | I tend to keep an open gvim window for this kind of things. Paste your class definition as is and then do something like:
```
:%s/^.*\.://
``` |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | How about using `%hist n` to print line `n` (or a range of lines) without prompts (including line continuations), and doing your copy from that? (Simply scrolling back to that line is nearly as good).
```
In [1]: def foo():
...: return 1+2
...:
In [6]: %history 1
def foo():
return 1+2
``` | One of the cool features of `ipython` is [session logging](http://ipython.org/ipython-doc/rel-1.1.0/interactive/reference.html#session-logging-and-restoring). If you enable it, the code you input in your session is logged to a file. It's very useful, I use it all the time.
To make things even niftier for me, I have a ... |
20,858,336 | I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:
```
class notathing(object):
...:
...: def __init__(self):
...: pass
...:
```
Is there any way to copy them without those leading triple dots and doublecolon?
P.S. I tried both `Cop... | 2013/12/31 | [
"https://Stackoverflow.com/questions/20858336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2022518/"
] | How about using `%hist n` to print line `n` (or a range of lines) without prompts (including line continuations), and doing your copy from that? (Simply scrolling back to that line is nearly as good).
```
In [1]: def foo():
...: return 1+2
...:
In [6]: %history 1
def foo():
return 1+2
``` | This QTconsole copy regression has been fixed, see <https://github.com/ipython/ipython/issues/3206> - I can confirm that the desired behavior is again present in the QtConsole in the Canopy 1.2 GUI and, I suspect, in the ipython egg installable by free users from the Enthought egg repo. |
14,198,382 | I have some Entrys in a python list.Each Entry has a creation date and creation time.The values are stored as python datetime.date and datetime.time (as two separate fields).I need to get the list of Entrys sorted sothat previously created Entry comes before the others.
I know there is a list.sort() function that acce... | 2013/01/07 | [
"https://Stackoverflow.com/questions/14198382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291096/"
] | You probably want something like:
```
my_entries_list.sort(key=lambda v:
datetime.datetime.combine(v.created_date, v.created_time))
```
Passing `datetime.datetime.combine(created_date, created_time)` tries to call `combine` immediately and breaks since `created_date` and `created_time` are... | Use `lambda`:
```
sorted(my_entries_list,
key=lambda e: datetime.combine(e.created_date, e.created_time))
``` |
14,198,382 | I have some Entrys in a python list.Each Entry has a creation date and creation time.The values are stored as python datetime.date and datetime.time (as two separate fields).I need to get the list of Entrys sorted sothat previously created Entry comes before the others.
I know there is a list.sort() function that acce... | 2013/01/07 | [
"https://Stackoverflow.com/questions/14198382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291096/"
] | Use `lambda`:
```
sorted(my_entries_list,
key=lambda e: datetime.combine(e.created_date, e.created_time))
``` | From the [documentation](http://docs.python.org/2/library/stdtypes.html#mutable-sequence-types)
>
> key specifies a function of one argument that is used to extract a comparison key from each list element
>
>
>
eg.
```
def combined_date_key(elem):
return datetime.datetime.combine(v.created_date, v.created_ti... |
14,198,382 | I have some Entrys in a python list.Each Entry has a creation date and creation time.The values are stored as python datetime.date and datetime.time (as two separate fields).I need to get the list of Entrys sorted sothat previously created Entry comes before the others.
I know there is a list.sort() function that acce... | 2013/01/07 | [
"https://Stackoverflow.com/questions/14198382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291096/"
] | Use `lambda`:
```
sorted(my_entries_list,
key=lambda e: datetime.combine(e.created_date, e.created_time))
``` | It may be slightly faster to use a tuple like this:
```
sorted(my_entries_list,
key = lambda e: (e.created_date, e.created_time))
```
Then things will be sorted by date, and only if the dates match will the time be considered. |
14,198,382 | I have some Entrys in a python list.Each Entry has a creation date and creation time.The values are stored as python datetime.date and datetime.time (as two separate fields).I need to get the list of Entrys sorted sothat previously created Entry comes before the others.
I know there is a list.sort() function that acce... | 2013/01/07 | [
"https://Stackoverflow.com/questions/14198382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291096/"
] | You probably want something like:
```
my_entries_list.sort(key=lambda v:
datetime.datetime.combine(v.created_date, v.created_time))
```
Passing `datetime.datetime.combine(created_date, created_time)` tries to call `combine` immediately and breaks since `created_date` and `created_time` are... | From the [documentation](http://docs.python.org/2/library/stdtypes.html#mutable-sequence-types)
>
> key specifies a function of one argument that is used to extract a comparison key from each list element
>
>
>
eg.
```
def combined_date_key(elem):
return datetime.datetime.combine(v.created_date, v.created_ti... |
14,198,382 | I have some Entrys in a python list.Each Entry has a creation date and creation time.The values are stored as python datetime.date and datetime.time (as two separate fields).I need to get the list of Entrys sorted sothat previously created Entry comes before the others.
I know there is a list.sort() function that acce... | 2013/01/07 | [
"https://Stackoverflow.com/questions/14198382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291096/"
] | You probably want something like:
```
my_entries_list.sort(key=lambda v:
datetime.datetime.combine(v.created_date, v.created_time))
```
Passing `datetime.datetime.combine(created_date, created_time)` tries to call `combine` immediately and breaks since `created_date` and `created_time` are... | It may be slightly faster to use a tuple like this:
```
sorted(my_entries_list,
key = lambda e: (e.created_date, e.created_time))
```
Then things will be sorted by date, and only if the dates match will the time be considered. |
14,198,382 | I have some Entrys in a python list.Each Entry has a creation date and creation time.The values are stored as python datetime.date and datetime.time (as two separate fields).I need to get the list of Entrys sorted sothat previously created Entry comes before the others.
I know there is a list.sort() function that acce... | 2013/01/07 | [
"https://Stackoverflow.com/questions/14198382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291096/"
] | From the [documentation](http://docs.python.org/2/library/stdtypes.html#mutable-sequence-types)
>
> key specifies a function of one argument that is used to extract a comparison key from each list element
>
>
>
eg.
```
def combined_date_key(elem):
return datetime.datetime.combine(v.created_date, v.created_ti... | It may be slightly faster to use a tuple like this:
```
sorted(my_entries_list,
key = lambda e: (e.created_date, e.created_time))
```
Then things will be sorted by date, and only if the dates match will the time be considered. |
17,601,602 | First, I'm extremely new to coding and self-taught, so models / views / DOM fall on deaf ears (but willing to learn!)
So I saved images into a database as blobs (BlobProperty), now trying to serve them.
**Relevant Code:** (I took out a ton for ease of reading)
```
class Mentors(db.Model):
id = db.StringProperty... | 2013/07/11 | [
"https://Stackoverflow.com/questions/17601602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/646491/"
] | In the handler, you're getting the ID from `self.request.get('mentor_id')`. However, in the template you've set the image URL to `imageit?key=whatever` - so the parameter is "key" not "mentor\_id". Choose one or the other. | Finally figured it out.
I'm using a subdomain, and wasn't setting up *that* route, only /img coming off of the www root.
I also wasn't using the URL correctly and the 15th pass of <https://developers.google.com/appengine/articles/python/serving_dynamic_images> finally answered my problem. |
47,528,696 | I am new about docker, so ,if any wrong thoughts come from me ,please point out it.Thanks~
I aim at running a web server that was developed by me ,or a team I belong to,in the docker.
So, I thought out three steps:
Have a image ,copy the web files into it,and run the container.so,I do the step below:
1- get a docke... | 2017/11/28 | [
"https://Stackoverflow.com/questions/47528696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8948738/"
] | You have docker images and docker container. That is different.
You pull or build images.
When you launch an image, it becomes a running container.
An image is not a running container, and so, you will not be able to copy a file inside an image.
I do not know if this what you want to do, but you may
1) launch an ... | I aimed at deploying a python web project by docker,and the first method I thought about is :copy server files to a container and run it with `python ***.py`.
But I did not get the difference between images and container.
Also,I got some other methods:
1- build a Dcokerfile. By this way,we can run a image with out o... |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | This is the jsFiddle with your expectations:
[jsFiddle](https://jsfiddle.net/y277r5zL/)
as you wanted the yellow border be around the whole content so it was better to extend your wrapper height.
```css
#wrapper{
border: 1px solid #F68004;
height: 150px;
}
#content{
background-color: #0075CF;
height: ... | try this
**CSS**
```
#wrapper{
border: 1px solid #F68004;
}
#content{
background-color: #0075CF;
height: 100px;
margin-bottom: 50px;
}
``` |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | The reason why the margin appears to be on top is due to [margin collapsing](https://developer.mozilla.org/en-US/docs/Web/CSS/margin_collapsing):
**Parent and first/last child**
If there is no border, padding, inline content, or clearance to separate the margin-top of a block with the margin-top of its first child ... | Solution 1:
```
<div id="wrapper">
<div id="content">
</div>
<div id="box"></div>
</div>
```
Solution 2:
```
<div id="wrapper">
<div id="content">
<div id="box"></div>
</div>
</div>
<style>
#wrapper{
border: 1px solid #F68004;
height: 150px;
}
#content{
backgrou... |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | You should give the margin to #content instead of #box.
And if you want to give margin to #box only. Try to give it with minus value i.e. -(50+div height)
If div #box height is 150px then use-
```css
#box {
margin-bottom: -200px;
}
``` | try this
**CSS**
```
#wrapper{
border: 1px solid #F68004;
}
#content{
background-color: #0075CF;
height: 100px;
margin-bottom: 50px;
}
``` |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | Give `margin-bottom: 50px;` to `#content` instead of `#box` Because you have given height to `#content` div and here margin collapse.
[Here it is explain with example](http://www.sitepoint.com/web-foundations/collapsing-margins/)
**[Updated Fiddle](https://jsfiddle.net/7drzfb9x/)** | Please check below code
```
#content {
background-color: #0075cf;
height: 100px;
margin-bottom: 50px;
}
#box{
/* margin-bottom: 50px; */
}
``` |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | This is the jsFiddle with your expectations:
[jsFiddle](https://jsfiddle.net/y277r5zL/)
as you wanted the yellow border be around the whole content so it was better to extend your wrapper height.
```css
#wrapper{
border: 1px solid #F68004;
height: 150px;
}
#content{
background-color: #0075CF;
height: ... | Please check below code
```
#content {
background-color: #0075cf;
height: 100px;
margin-bottom: 50px;
}
#box{
/* margin-bottom: 50px; */
}
``` |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | You should give the margin to #content instead of #box.
And if you want to give margin to #box only. Try to give it with minus value i.e. -(50+div height)
If div #box height is 150px then use-
```css
#box {
margin-bottom: -200px;
}
``` | Solution 1:
```
<div id="wrapper">
<div id="content">
</div>
<div id="box"></div>
</div>
```
Solution 2:
```
<div id="wrapper">
<div id="content">
<div id="box"></div>
</div>
</div>
<style>
#wrapper{
border: 1px solid #F68004;
height: 150px;
}
#content{
backgrou... |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | Give `margin-bottom: 50px;` to `#content` instead of `#box` Because you have given height to `#content` div and here margin collapse.
[Here it is explain with example](http://www.sitepoint.com/web-foundations/collapsing-margins/)
**[Updated Fiddle](https://jsfiddle.net/7drzfb9x/)** | You should give the margin to #content instead of #box.
And if you want to give margin to #box only. Try to give it with minus value i.e. -(50+div height)
If div #box height is 150px then use-
```css
#box {
margin-bottom: -200px;
}
``` |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | Please check below code
```
#content {
background-color: #0075cf;
height: 100px;
margin-bottom: 50px;
}
#box{
/* margin-bottom: 50px; */
}
``` | Solution 1:
```
<div id="wrapper">
<div id="content">
</div>
<div id="box"></div>
</div>
```
Solution 2:
```
<div id="wrapper">
<div id="content">
<div id="box"></div>
</div>
</div>
<style>
#wrapper{
border: 1px solid #F68004;
height: 150px;
}
#content{
backgrou... |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | The reason why the margin appears to be on top is due to [margin collapsing](https://developer.mozilla.org/en-US/docs/Web/CSS/margin_collapsing):
**Parent and first/last child**
If there is no border, padding, inline content, or clearance to separate the margin-top of a block with the margin-top of its first child ... | Please check below code
```
#content {
background-color: #0075cf;
height: 100px;
margin-bottom: 50px;
}
#box{
/* margin-bottom: 50px; */
}
``` |
35,887,597 | I am new in Odoo development. I want to add product brand and country for the products. I just created the form view and menu for the brand under product menu in warehouse. Now I want to add a field for the brand in product view. I am trying to extend the product.product model for it but the model not found error occur... | 2016/03/09 | [
"https://Stackoverflow.com/questions/35887597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123488/"
] | Give `margin-bottom: 50px;` to `#content` instead of `#box` Because you have given height to `#content` div and here margin collapse.
[Here it is explain with example](http://www.sitepoint.com/web-foundations/collapsing-margins/)
**[Updated Fiddle](https://jsfiddle.net/7drzfb9x/)** | You can try like this: **[Demo](https://jsfiddle.net/gvLeto9b/1/)**
Instead of setting height to `#content`, you can use it for `#box`
```
#content {
background-color: #0075CF;
}
#box {margin-bottom: 50px; height: 100px;}
``` |
54,262,301 | I downloaded openCV and YOLO weights, in order to implement object detection for a certain project using Python 3.5 version.
when I run this code:
```python
from yolo_utils import read_classes, read_anchors, generate_colors, preprocess_image, draw_boxes, scale_boxes
from yad2k.models.keras_yolo import yolo_head, yol... | 2019/01/18 | [
"https://Stackoverflow.com/questions/54262301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10935479/"
] | Actually You are Importing user built module. As Yolo\_utils is created by a Coursera coordinators to make things easy, this module is available in only their machines and You are trying to import this in your machine.
Here is github link of module :
<https://github.com/JudasDie/deeplearning.ai/blob/master/Convolutiona... | Copy the source code of [yolo\_utils](https://github.com/iArunava/YOLOv3-Object-Detection-with-OpenCV/blob/master/yolo_utils.py) .
Paste it in your source code before importing yolo\_utils.
It worked for me.
Hope this will help.. |
10,135,656 | I had an existing Django project that I've just added South to.
* I ran syncdb locally.
* I ran `manage.py schemamigration app_name` locally
* I ran `manage.py migrate app_name --fake` locally
* I commit and pushed to heroku master
* I ran syncdb on heroku
* I ran `manage.py schemamigration app_name` on heroku
* I ran... | 2012/04/13 | [
"https://Stackoverflow.com/questions/10135656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/722427/"
] | You must fake the migrations that create the tables, then run the other migrations as usual.
```
manage.py migrate app_name 000X --fake
manage.py migrate app_name
```
With 000X being the number of the migration in which you create the table. | First of all, from the looks of 0003\_initial and 0005\_initial, you've done multiple `schemamigration myapp --initial` commands which add create\_table statements. Having two sets of these will definitely cause problems as one will create tables, then the next one will attempt creating existing tables.
Your `migratio... |
64,160,347 | I am trying to replicate a Case Statement within my python script (involving pandas) that is applied to a dataframe and fills a new column based on how each row is processed, but it seems like every row is falling into the else condition due to every value in the new column being `Other`. My first thought is that it is... | 2020/10/01 | [
"https://Stackoverflow.com/questions/64160347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1061892/"
] | I figured out a better approach to the problem. Rather than using contains methods, I decided to run a regex search to see if the combined list values are found within the column row and if they are present, then apply that value. Found below are my updates:
**Lists:**
```
fb_landing_page_crit = [
'utm_source=fac... | Right now, the problem is not the `any` but the `x in df['source_name']` part (I took `source_name` as it is simpler to explain there). You check if any row of the dataframe is *equal* to (e.g.) `'Google'`, not if it contains the word. To achieve the latter, you could nest the `for` statements:
```
...
if any((x in y ... |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | In python, if you declare an array like:
```
myarray = []
```
You are declaring an empty array with head -1, and you can append values to it with the .append() function and access them the same way you would in java. For all intents and purposes, they are the same thing | It's easer to use collections.deque for stacks in python.
```
from collections import deque
stack = deque()
stack.append(1) # push
stack.append(2) # push
stack.append(3) # push
stack.append(4) # push
t = stack[-1] # your 'head()'
tt = stack.pop() # pop
if not len(stack): # empty()
print("It's empty")
``` |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | Fist of all, you need to distinguish between arrays and lists in Python.
What you are talking about here is `list` class, but there are [actual arrays](https://docs.python.org/3/library/array.html) and they are more or less the same as arrays in Java.
Python's `list` is similar to Java's `ArrayList` and to C++'s `std:... | In python, if you declare an array like:
```
myarray = []
```
You are declaring an empty array with head -1, and you can append values to it with the .append() function and access them the same way you would in java. For all intents and purposes, they are the same thing |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | In python, if you declare an array like:
```
myarray = []
```
You are declaring an empty array with head -1, and you can append values to it with the .append() function and access them the same way you would in java. For all intents and purposes, they are the same thing | This is the same code from Java to Python:
```
class IntegerStack:
def __init__(self):
self._stack = []
self._head = -1
def emptyStack(self):
return self._head < 0
def head(self):
if self._head < 0:
raise Exception("The stack is empty.")
return self._s... |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | If you want to implement something close to your java version, you could use a numpy array by importing numpy. Numpy arrays are similar because they are immutable objects like in java. Then you could write in your constructor:
```py
_stack = np.zeros(MAX_NUMBER)
```
Otherwise you could use the mutable list objec... | In python, if you declare an array like:
```
myarray = []
```
You are declaring an empty array with head -1, and you can append values to it with the .append() function and access them the same way you would in java. For all intents and purposes, they are the same thing |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | Fist of all, you need to distinguish between arrays and lists in Python.
What you are talking about here is `list` class, but there are [actual arrays](https://docs.python.org/3/library/array.html) and they are more or less the same as arrays in Java.
Python's `list` is similar to Java's `ArrayList` and to C++'s `std:... | It's easer to use collections.deque for stacks in python.
```
from collections import deque
stack = deque()
stack.append(1) # push
stack.append(2) # push
stack.append(3) # push
stack.append(4) # push
t = stack[-1] # your 'head()'
tt = stack.pop() # pop
if not len(stack): # empty()
print("It's empty")
``` |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | This is the same code from Java to Python:
```
class IntegerStack:
def __init__(self):
self._stack = []
self._head = -1
def emptyStack(self):
return self._head < 0
def head(self):
if self._head < 0:
raise Exception("The stack is empty.")
return self._s... | It's easer to use collections.deque for stacks in python.
```
from collections import deque
stack = deque()
stack.append(1) # push
stack.append(2) # push
stack.append(3) # push
stack.append(4) # push
t = stack[-1] # your 'head()'
tt = stack.pop() # pop
if not len(stack): # empty()
print("It's empty")
``` |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | If you want to implement something close to your java version, you could use a numpy array by importing numpy. Numpy arrays are similar because they are immutable objects like in java. Then you could write in your constructor:
```py
_stack = np.zeros(MAX_NUMBER)
```
Otherwise you could use the mutable list objec... | It's easer to use collections.deque for stacks in python.
```
from collections import deque
stack = deque()
stack.append(1) # push
stack.append(2) # push
stack.append(3) # push
stack.append(4) # push
t = stack[-1] # your 'head()'
tt = stack.pop() # pop
if not len(stack): # empty()
print("It's empty")
``` |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | Fist of all, you need to distinguish between arrays and lists in Python.
What you are talking about here is `list` class, but there are [actual arrays](https://docs.python.org/3/library/array.html) and they are more or less the same as arrays in Java.
Python's `list` is similar to Java's `ArrayList` and to C++'s `std:... | This is the same code from Java to Python:
```
class IntegerStack:
def __init__(self):
self._stack = []
self._head = -1
def emptyStack(self):
return self._head < 0
def head(self):
if self._head < 0:
raise Exception("The stack is empty.")
return self._s... |
58,971,323 | I have an assignment in my class to implement something in Java and Python. I need to implement an IntegerStack with both languages. All the values are supposed to be held in an array and there are some meta data values like head() index.
When I implement this is Java I just create an Array with max size (that I choos... | 2019/11/21 | [
"https://Stackoverflow.com/questions/58971323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10137268/"
] | If you want to implement something close to your java version, you could use a numpy array by importing numpy. Numpy arrays are similar because they are immutable objects like in java. Then you could write in your constructor:
```py
_stack = np.zeros(MAX_NUMBER)
```
Otherwise you could use the mutable list objec... | This is the same code from Java to Python:
```
class IntegerStack:
def __init__(self):
self._stack = []
self._head = -1
def emptyStack(self):
return self._head < 0
def head(self):
if self._head < 0:
raise Exception("The stack is empty.")
return self._s... |
5,325,858 | I need to perform http PUT operations from python Which libraries have been proven to support this? More specifically I need to perform PUT on keypairs, not file upload.
I have been trying to work with the restful\_lib.py, but I get invalid results from the API that I am testing. (I know the results are invalid becaus... | 2011/03/16 | [
"https://Stackoverflow.com/questions/5325858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/662525/"
] | httplib should manage.
<http://docs.python.org/library/httplib.html>
There's an example on this page <http://effbot.org/librarybook/httplib.htm> | [urllib](http://docs.python.org/library/urllib.html) and [urllib2](http://docs.python.org/library/urllib2.html) are also suggested. |
5,325,858 | I need to perform http PUT operations from python Which libraries have been proven to support this? More specifically I need to perform PUT on keypairs, not file upload.
I have been trying to work with the restful\_lib.py, but I get invalid results from the API that I am testing. (I know the results are invalid becaus... | 2011/03/16 | [
"https://Stackoverflow.com/questions/5325858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/662525/"
] | httplib should manage.
<http://docs.python.org/library/httplib.html>
There's an example on this page <http://effbot.org/librarybook/httplib.htm> | Thank you all for your assistance. I think I have found an answer.
My code now looks like this:
```
import urllib
import httplib
import lxml
from lxml import etree
url='xxxx.com'
UAM=httplib.HTTPSConnection(url)
arglist= [\
('username', '[email protected]'),\
('email', '[email protected]'),\
('u... |
5,325,858 | I need to perform http PUT operations from python Which libraries have been proven to support this? More specifically I need to perform PUT on keypairs, not file upload.
I have been trying to work with the restful\_lib.py, but I get invalid results from the API that I am testing. (I know the results are invalid becaus... | 2011/03/16 | [
"https://Stackoverflow.com/questions/5325858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/662525/"
] | [urllib](http://docs.python.org/library/urllib.html) and [urllib2](http://docs.python.org/library/urllib2.html) are also suggested. | Thank you all for your assistance. I think I have found an answer.
My code now looks like this:
```
import urllib
import httplib
import lxml
from lxml import etree
url='xxxx.com'
UAM=httplib.HTTPSConnection(url)
arglist= [\
('username', '[email protected]'),\
('email', '[email protected]'),\
('u... |
26,699,356 | i am using Spyder 2.3.1 under Windows 7 and have a running iPython 2.3 Kernel on a Rasperry Pi RASPBIAN Linux OS.
I can connect to an external kernel, using a .json file and this tutorial:
[Remote ipython console](https://pythonhosted.org/spyder/ipythonconsole.html)
But what now? If I "run" a script (F5), then the ke... | 2014/11/02 | [
"https://Stackoverflow.com/questions/26699356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4153871/"
] | The tutorial that you mention is a little bit our of date as Spyder now has the ability to connect to remote kernels.
The "This is a remote kernel" checkbox, when checked, enables the portion of the dialog where you can enter your ssh connection credentials.
(You should need this unless you have manually opened the r... | Another option is to use Spyder cells to send the whole contents of your file to the IPython console. I think this is easier than mounting your remote filesystem with Samba or sshfs (in case that's not possible or hard to do).
Cells are defined by adding lines of the form `# %%` to your file. For example, let's say yo... |
26,699,356 | i am using Spyder 2.3.1 under Windows 7 and have a running iPython 2.3 Kernel on a Rasperry Pi RASPBIAN Linux OS.
I can connect to an external kernel, using a .json file and this tutorial:
[Remote ipython console](https://pythonhosted.org/spyder/ipythonconsole.html)
But what now? If I "run" a script (F5), then the ke... | 2014/11/02 | [
"https://Stackoverflow.com/questions/26699356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4153871/"
] | The tutorial that you mention is a little bit our of date as Spyder now has the ability to connect to remote kernels.
The "This is a remote kernel" checkbox, when checked, enables the portion of the dialog where you can enter your ssh connection credentials.
(You should need this unless you have manually opened the r... | After a search in the `site-packages\spyderlib` directory for the keyword `%run`, I found the method(in `site-packages\spyderlib\plugins\ipythonconsole.py`) which constructs the `%run` command:
```
def run_script_in_current_client(self, filename, wdir, args, debug):
"""Run script in current client, if any"""
... |
26,699,356 | i am using Spyder 2.3.1 under Windows 7 and have a running iPython 2.3 Kernel on a Rasperry Pi RASPBIAN Linux OS.
I can connect to an external kernel, using a .json file and this tutorial:
[Remote ipython console](https://pythonhosted.org/spyder/ipythonconsole.html)
But what now? If I "run" a script (F5), then the ke... | 2014/11/02 | [
"https://Stackoverflow.com/questions/26699356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4153871/"
] | The tutorial that you mention is a little bit our of date as Spyder now has the ability to connect to remote kernels.
The "This is a remote kernel" checkbox, when checked, enables the portion of the dialog where you can enter your ssh connection credentials.
(You should need this unless you have manually opened the r... | Just thought I'd make my first post to update Roy Cai's answer for Spyder 4 in case anyone is looking for this. Roy's answer worked flawlessly for me. Spyder 4 has moved the relevant code from where it was when he wrote the answer. The method is now in \Lib\site-packages\spyder\plugins\ipythonconsole and the python fil... |
74,180,540 | i'm trying execute project python in terminal but appear this error:
```
(base) hopu@docker-manager1:~/bentoml-airquality$ python src/main.py
Traceback (most recent call last):
File "src/main.py", line 7, in <module>
from src import VERSION, SERVICE, DOCKER_IMAGE_NAME
ModuleNotFoundError: No module named 'src'
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15767572/"
] | Your PYTHONPATH is determined by the directory your python executable is located, not from where you're executing it. For this reason, you should be able to import the files directly, and not from source. You're trying to import from `/src`, but your path is already in there. Maybe something like this might work:
```p... | The interpretor is right. For `from src import VERSION, SERVICE, DOCKER_IMAGE_NAME` to be valid, `src` has to be a module or package accessible from the Python path. The problem is that the `python` program looks in the current directory to search for the modules or packages to run, but the current directory is not add... |
68,555,515 | I am pretty new to python and webscraping, but I have managed to get a well working table to print, I am just curious how I would get this table into a CSV file in the exact same format as the print statement. Any logic explanations would be greatly appreciated and very helpful! My code is below...
```
from bs4 import... | 2021/07/28 | [
"https://Stackoverflow.com/questions/68555515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16523958/"
] | The charges API allows specifying a description.
The description can be anything you want. It's your own tidbit of info you can have added to each transaction.
When you export transactions on the Stripe site to a CSV, the description can be exported too. I assume it can be extracted with their APIs as well.
Would th... | There isn't really a way to do this on the Stripe dashboard, but you can certainly build something like this yourself.
You'd start by [retrieving](https://stripe.com/docs/api/checkout/sessions/list) all the Checkout Sessions, then loop over the list and add up the [totals](https://stripe.com/docs/api/checkout/sessions... |
71,213,873 | I've been trying to run through this tutorial (<https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html>) for the past day and constantly get an error after running this portion:
`bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)`
The error is the following:
```
Traceback (most recent call last):
File... | 2022/02/21 | [
"https://Stackoverflow.com/questions/71213873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18272784/"
] | It seems that `ax.set_yscale("log", basey=10)` does not recognise keyword argument `basey`. This keyword was replaced in the most recent matplotlib releases if you would install an older version it should work:
`pip install matplotlib==3.3.4`
So why is this happening in the first place? The package you are using does... | I looked for posts with a similar issue ("wrong" keyword calls on **init**) in Github and SO and it seems like you might need to update your matplotlib:
```
sudo pip install --upgrade matplotlib # for Linux
sudo pip install matplotlib --upgrade # for Windows
``` |
71,213,873 | I've been trying to run through this tutorial (<https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html>) for the past day and constantly get an error after running this portion:
`bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)`
The error is the following:
```
Traceback (most recent call last):
File... | 2022/02/21 | [
"https://Stackoverflow.com/questions/71213873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18272784/"
] | It seems that `ax.set_yscale("log", basey=10)` does not recognise keyword argument `basey`. This keyword was replaced in the most recent matplotlib releases if you would install an older version it should work:
`pip install matplotlib==3.3.4`
So why is this happening in the first place? The package you are using does... | I think it is because of the version issues.
In the version 3.6.0 of matplotlib, the keywords like "basey" or "susby" have been changed. More details could be find in
[matplotlib.scale.LogScale](https://matplotlib.org/stable/api/scale_api.html#matplotlib.scale.LogScale) and [yscale](https://matplotlib.org/stable/api/_... |
71,213,873 | I've been trying to run through this tutorial (<https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html>) for the past day and constantly get an error after running this portion:
`bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)`
The error is the following:
```
Traceback (most recent call last):
File... | 2022/02/21 | [
"https://Stackoverflow.com/questions/71213873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18272784/"
] | It seems that `ax.set_yscale("log", basey=10)` does not recognise keyword argument `basey`. This keyword was replaced in the most recent matplotlib releases if you would install an older version it should work:
`pip install matplotlib==3.3.4`
So why is this happening in the first place? The package you are using does... | I had a similar problem when I tried to scale the y-axis of my plot logarithmically. Thereby the base should be 2. I had success when I tried base=2 instead of basey=2.
```
plt.yscale("log",base=2)
```
This should also work with the latest version of matplotlib. |
71,213,873 | I've been trying to run through this tutorial (<https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html>) for the past day and constantly get an error after running this portion:
`bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)`
The error is the following:
```
Traceback (most recent call last):
File... | 2022/02/21 | [
"https://Stackoverflow.com/questions/71213873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18272784/"
] | I looked for posts with a similar issue ("wrong" keyword calls on **init**) in Github and SO and it seems like you might need to update your matplotlib:
```
sudo pip install --upgrade matplotlib # for Linux
sudo pip install matplotlib --upgrade # for Windows
``` | I think it is because of the version issues.
In the version 3.6.0 of matplotlib, the keywords like "basey" or "susby" have been changed. More details could be find in
[matplotlib.scale.LogScale](https://matplotlib.org/stable/api/scale_api.html#matplotlib.scale.LogScale) and [yscale](https://matplotlib.org/stable/api/_... |
71,213,873 | I've been trying to run through this tutorial (<https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html>) for the past day and constantly get an error after running this portion:
`bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)`
The error is the following:
```
Traceback (most recent call last):
File... | 2022/02/21 | [
"https://Stackoverflow.com/questions/71213873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18272784/"
] | I had a similar problem when I tried to scale the y-axis of my plot logarithmically. Thereby the base should be 2. I had success when I tried base=2 instead of basey=2.
```
plt.yscale("log",base=2)
```
This should also work with the latest version of matplotlib. | I looked for posts with a similar issue ("wrong" keyword calls on **init**) in Github and SO and it seems like you might need to update your matplotlib:
```
sudo pip install --upgrade matplotlib # for Linux
sudo pip install matplotlib --upgrade # for Windows
``` |
71,213,873 | I've been trying to run through this tutorial (<https://bedapub.github.io/besca/tutorials/scRNAseq_tutorial.html>) for the past day and constantly get an error after running this portion:
`bc.pl.kp_genes(adata, min_genes=min_genes, ax = ax1)`
The error is the following:
```
Traceback (most recent call last):
File... | 2022/02/21 | [
"https://Stackoverflow.com/questions/71213873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18272784/"
] | I had a similar problem when I tried to scale the y-axis of my plot logarithmically. Thereby the base should be 2. I had success when I tried base=2 instead of basey=2.
```
plt.yscale("log",base=2)
```
This should also work with the latest version of matplotlib. | I think it is because of the version issues.
In the version 3.6.0 of matplotlib, the keywords like "basey" or "susby" have been changed. More details could be find in
[matplotlib.scale.LogScale](https://matplotlib.org/stable/api/scale_api.html#matplotlib.scale.LogScale) and [yscale](https://matplotlib.org/stable/api/_... |
65,383,598 | I have read some posts but I have not been able to get what I want.
I have a dataframe with ~4k rows and a few columns which I exported from Infoblox (DNS server).
One of them is dhcp attributes and I would like to expand it to have separated values.
This is my df (I attach a screenshot from excel):
[excel screenshot](... | 2020/12/20 | [
"https://Stackoverflow.com/questions/65383598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13546976/"
] | You seem to be a little confused about [variable scope](https://www.php.net/manual/en/language.variables.scope.php). There's also an errant `$` in `$this->$cards`. While this [is valid syntax](https://www.php.net/manual/en/language.variables.variable.php), it's not doing what you expect.
Consider the following to get ... | In this case you don't need a 'global' keyword. Just access your class attributes using $this keyword.
```
class GamesManager extends Main {
protected $DB;
public $cards = array();
public function __construct() {
$this->cards = array('2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | you could try to find 2 lines (with lookahead inside it to avoid capturing the linefeed) or only one (to process the last, odd line). I expanded your example to show that it works for more than 3 lines (with a little "cheat": adding a newline in the end to handle all cases:
```
import re
s = "Line 1\nLine 2\nLine 3\n... | I wanted to post the grouper recipe from the itertools docs as well, but [PyToolz' `partition_all`](https://toolz.readthedocs.io/en/latest/api.html#toolz.itertoolz.partition_all) is actually a bit nicer.
```
from toolz import partition_all
s = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
result = ['\n'.join(tup) for tup ... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | I'm hoping I get your logic right - If you want a list of string, each with *at most one* newline delimiter, then the following code snippet will work:
```
# Newline-delimited string
a = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7"
# Resulting list
b = []
# First split the string into "1-line-long" pieces... | Use [str.splitlines()](https://www.tutorialspoint.com/python/string_splitlines.htm) to split the full input into lines:
```
>>> inputString = "Line 1\nLine 2\nLine 3"
>>> outputStringList = inputString.splitlines()
>>> print(outputStringList)
['Line 1', 'Line 2', 'Line 3']
```
Then, join the first lines to obtain th... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | Here is an alternative using the [`grouper` itertools recipe](https://more-itertools.readthedocs.io/en/latest/api.html#more_itertools.grouper) to group any number of lines together.
*Note: you can implement this recipe by hand, or you can optionally install a third-party library that implements this recipe for you, i.... | ```
b = "a\nb\nc\nd".split("\n", 3)
c = ["\n".join(b[:-1]), b[-1]]
print c
```
gives
```
['a\nb\nc', 'd']
``` |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | Here is an alternative using the [`grouper` itertools recipe](https://more-itertools.readthedocs.io/en/latest/api.html#more_itertools.grouper) to group any number of lines together.
*Note: you can implement this recipe by hand, or you can optionally install a third-party library that implements this recipe for you, i.... | I'm hoping I get your logic right - If you want a list of string, each with *at most one* newline delimiter, then the following code snippet will work:
```
# Newline-delimited string
a = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7"
# Resulting list
b = []
# First split the string into "1-line-long" pieces... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | I wanted to post the grouper recipe from the itertools docs as well, but [PyToolz' `partition_all`](https://toolz.readthedocs.io/en/latest/api.html#toolz.itertoolz.partition_all) is actually a bit nicer.
```
from toolz import partition_all
s = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
result = ['\n'.join(tup) for tup ... | I'm not sure what you mean by "a maximum of 2 lines" and how you'd hope to achieve that. However, splitting on newlines is fairly simple.
```
'Line 1\nLine 2\nLine 3'.split('\n')
```
This will result in:
```
['line 1', 'line 2', 'line 3']
```
To get the weird allowance for "some" line splitting, you'll have to wr... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | you could try to find 2 lines (with lookahead inside it to avoid capturing the linefeed) or only one (to process the last, odd line). I expanded your example to show that it works for more than 3 lines (with a little "cheat": adding a newline in the end to handle all cases:
```
import re
s = "Line 1\nLine 2\nLine 3\n... | I'm hoping I get your logic right - If you want a list of string, each with *at most one* newline delimiter, then the following code snippet will work:
```
# Newline-delimited string
a = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7"
# Resulting list
b = []
# First split the string into "1-line-long" pieces... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | I wanted to post the grouper recipe from the itertools docs as well, but [PyToolz' `partition_all`](https://toolz.readthedocs.io/en/latest/api.html#toolz.itertoolz.partition_all) is actually a bit nicer.
```
from toolz import partition_all
s = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
result = ['\n'.join(tup) for tup ... | Use [str.splitlines()](https://www.tutorialspoint.com/python/string_splitlines.htm) to split the full input into lines:
```
>>> inputString = "Line 1\nLine 2\nLine 3"
>>> outputStringList = inputString.splitlines()
>>> print(outputStringList)
['Line 1', 'Line 2', 'Line 3']
```
Then, join the first lines to obtain th... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | Here is an alternative using the [`grouper` itertools recipe](https://more-itertools.readthedocs.io/en/latest/api.html#more_itertools.grouper) to group any number of lines together.
*Note: you can implement this recipe by hand, or you can optionally install a third-party library that implements this recipe for you, i.... | I wanted to post the grouper recipe from the itertools docs as well, but [PyToolz' `partition_all`](https://toolz.readthedocs.io/en/latest/api.html#toolz.itertoolz.partition_all) is actually a bit nicer.
```
from toolz import partition_all
s = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
result = ['\n'.join(tup) for tup ... |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | I'm hoping I get your logic right - If you want a list of string, each with *at most one* newline delimiter, then the following code snippet will work:
```
# Newline-delimited string
a = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7"
# Resulting list
b = []
# First split the string into "1-line-long" pieces... | ```
b = "a\nb\nc\nd".split("\n", 3)
c = ["\n".join(b[:-1]), b[-1]]
print c
```
gives
```
['a\nb\nc', 'd']
``` |
46,234,207 | I have a multi-line string:
```
inputString = "Line 1\nLine 2\nLine 3"
```
I want to have an array, each element will have maximum 2 lines it it as below:
```
outputStringList = ["Line 1\nLine2", "Line3"]
```
Can i convert inputString to outputStringList in python. Any help will be appreciated. | 2017/09/15 | [
"https://Stackoverflow.com/questions/46234207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8595590/"
] | Here is an alternative using the [`grouper` itertools recipe](https://more-itertools.readthedocs.io/en/latest/api.html#more_itertools.grouper) to group any number of lines together.
*Note: you can implement this recipe by hand, or you can optionally install a third-party library that implements this recipe for you, i.... | Use [str.splitlines()](https://www.tutorialspoint.com/python/string_splitlines.htm) to split the full input into lines:
```
>>> inputString = "Line 1\nLine 2\nLine 3"
>>> outputStringList = inputString.splitlines()
>>> print(outputStringList)
['Line 1', 'Line 2', 'Line 3']
```
Then, join the first lines to obtain th... |
47,659,731 | My code is running fine for first iteration but after that it outputs the following error:
```
ValueError: matrix must be 2-dimensional
```
To the best of my knowledge (which is not much in python), my code is correct. but I don't know, why it is not running correctly for all given iterations. Could anyone help me i... | 2017/12/05 | [
"https://Stackoverflow.com/questions/47659731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5507715/"
] | In a comment, you said,
>
> Yes that is the structure however const items, references, and class items can't be initialized in the body of constructors or in a non-constructor method.
>
>
>
A [delegating constructor](http://www.stroustrup.com/C++11FAQ.html#delegating-ctor) can be used to initialize reference memb... | So this is a restriction that you can't initialize const variables other than in the constructor so there is one approach in my mind. You can have one overloaded constructor with all the possible variable types as arguments and the last argument being the integer that represent which argument to take care off assuming ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.