Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
How to intepret data

How can i interpret this data? From multi regression

plt.scatter(ytest, ypredict)

​

https://preview.redd.it/pw8smowv0nf91.png?width=704&format=png&auto=webp&s=a220d2145a64e77d48ef76b42440fe8db48f4675

/r/IPython
https://redd.it/wfth9f
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/xdmrzi
how to change axis label in sns plot

my code

sns.countplot("gender", data=df,saturation=0.68)

I want to change the count to salary

https://preview.redd.it/fr7osqdjwgf91.png?width=1266&format=png&auto=webp&s=13b4ccc9490b0675535504cf89a1e6c86ebdac45

/r/IPython
https://redd.it/wf219i
I just wanna give a shout-out to my friends in the Django community

I work with a small business and I don’t get to use Django in my work environment (I’m working with PHP) but I come home and practice with Django, building small things. I love the framework. I hope to make it a professional thing sooner than later.

/r/django
https://redd.it/xdry91
djstripe admin cannot view synced plans or products



I have a problem when I use django admin to view products and prices in djstripe. I have synced everything on Stripe portal. I get an error Exception Type: TypeError at /admin/djstripe/plan/ Exception Value: 'NoneType' object is not subscriptable

How do I solve this? Been stuck here

/r/django
https://redd.it/xdwykx
django all auth twitter error

Can sb check my setup for twitter as a login provider?

settings.py


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.twitter',
'myapp',
'django_select2',
'django_tables2',
'django_filters',
'bootstrap4'
]


SITE_ID = 1




/r/django
https://redd.it/xdz9em
Having to stop Flask server to run other functions.



I'm currently trying to make a simple flask server that gets input from the local frontend, uses the input to get certain data from a CSV, and then send the data back to the frontend. (I'm brand new to python and web development).

The issue that I'm having is this:

When I run the program, it starts the server and I go onto the frontend and post the input to the backend. It then stores the input in a variable.

I then have to manually stop the server by pressing ctrl-c. This then allows the code after it to run. (The function to get data from the CSV).

Do I then have to automatically restart the server to then send the data to the frontend? This just seems too complicated, and I've been told that you can do all this without stopping the server at all in the first place. I heavily get the sense that I'm missing the trick somewhere, however I'm new to this so pls understand :).

Please let me know if the above makes no sense and I'll try to rephrase.

/r/flask
https://redd.it/xe46js
Making Jupyter notebooks more SQL-friendly?

As a data scientist, I spend a lot of time preparing SQL queries, usually in a Jupyter notebook; however, I feel the experience isn't smooth. After a few days of beginning some analysis, my notebook is full of copy-pasted SQL chunks and a weird mix of SQL and pandas.

Sometimes I use the [ipython-sql](https://github.com/catherinedevlin/ipython-sql) extension, allowing me to write simpler code than [pandas.read\_sql](https://pandas.pydata.org/docs/reference/api/pandas.read_sql.html). However, I think some features would come in handy.

Here's my wishlist:

* Facilitate writing large queries
* Choosing plotting backends like matplotlib, plotly, etc.
* Plot computation by the SQL engine

Anything I'm missing? What would it make a smooth SQL experience in Jupyter notebooks for you?

/r/IPython
https://redd.it/wb5fwh
3 models union function mixing up values

so I have this function



`def all(request):`
`movie = List.objects.all()`
`music = MusicList.objects.all()`
`book = BookList.objects.all()`

`a = movie.union(music)`
`allPosts = a.union(book)`

`# allPosts = List.objects.filter(title__search=query)`
`params = {'allPosts' : allPosts}`
`return render(request, 'app/all.html', params)`

All 3 models have same fields

​



`class List(models.Model):`
`title = models.CharField(max_length=65)`
`author = models.ForeignKey('Author',on_delete=models.SET_NULL,null=True)`
`genre = models.ManyToManyField('Genre')`
`posted = models.DateTimeField(auto_now_add=True)`
`content = RichTextField(null=True,default=' ')`
`type = models.CharField(max_length=10,default="Movie")`



`class BookList(models.Model):`
`title = models.CharField(max_length=65)`
`author = models.ForeignKey('Author',on_delete=models.SET_NULL,null=True)`
`genre = models.ManyToManyField('BookGenre')`
`posted = models.DateTimeField(auto_now_add=True)`
`content = RichTextField(null=True,default=' ')`
`type = models.CharField(max_length=10,default="book")`

​

and so on

​

in my template



`<div class="thumb">{{allPosts}}</div>`
`{% for lola in allPosts %}`
`<div class="elements">`
`<div class="thumb">`
`<img src="{% static 'app/images/movie-poster.jpg' %}" width="100px" />`
`</div>`
`<div class="Title">`
`{% comment %} <a href="{{lola.id}}/"><h4 class="tit">{{lola.title}}</h4></a> {% endcomment %}`
`<a href="{{lola.id}}/"><h4 class="tit">{{lola.title}}</h4></a>`
`</div>`
`<div class="Author">`
`<small>Author : {{lola.author}}<span>{{lola.posted}}</span></small>`
`</div>`
`<div

/r/django
https://redd.it/xe9bjo
How do I integrate Django rest with ckeditor?

Does anybody know a good tutorial that explains how to integrate Django rest Framework with ckeditor (or any similar editor). I am making a RESTfull API to be consumed with react. I would like to edit blog posts on Django Admin then use the endpoints in react. I have been googling for the same but I can not find a tutorial. Here's the project if you wanna look around. Thanks.

/r/django
https://redd.it/xea042
how to correct this error?

I want to show whether those who scored lower will have lower salary than those who scored higher.

https://preview.redd.it/yyenlky6e8e91.png?width=883&format=png&auto=webp&s=345422026e344d1cb24afdb33773d3999eebe63f

/r/IPython
https://redd.it/w9z77l
Machine Learning from Scratch with Python

Hey everyone!

I've seen a growing number of people looking for resources on how to implement Machine Learning algos from scratch to better understand how they work (rather than just applying e.g. sklearn).

This free **Machine Learning from Scratch Course** on YouTube takes you through writing 10 algorithms from scratch with nothing but Python and NumPy! The algorithms are:

1. K-Nearest Neighbors
2. Linear Regression
3. Logistic Regression
4. Decision Trees
5. Random Forest
6. Naive Bayes
7. PCA
8. Perceptron
9. SVM
10. K-Means

Hopefully some of my Python + ML friends will find this helpful! :)

/r/Python
https://redd.it/xe2mzy
Xarray variables

Is there any way to see xarray variables on variable inspector?

Thanks in advance.

/r/JupyterNotebooks
https://redd.it/xd2dg5
What kind of subplots is the best?

&#x200B;

https://preview.redd.it/pf4doyu36xd91.png?width=1234&format=png&auto=webp&s=903c951f219a64964871611a54462825e00435eb

Tried using the codes below but it is not the kind i wanted. I wanted 4 subplots with the xaxis as 'salary' or is there other way to show it?

plt.figure(figsize=(14,8))
sns.pairplot(df['ssc_p','hsc_p','degree_p','etest_p'], kind="reg")

/r/IPython
https://redd.it/w8kplp
Argument parsing/validation for flask?

Is there a way with flask to create some sort of argument serializer deserializer?

I really like in django how you can specify a serializier that take a requests urlparams/body and tells you which fields are correct, which are required and what format they need to be in.

I was hoping there might be an equivalent for endpoints that don't directly use a sqlalchemy/marshmallow serializer

thanks for any help!

/r/flask
https://redd.it/xe9r5v
CI/CD Django How to make this work: push to GitHub > run GitHub action (tests) > auto deploy app if tests passed?

Hello guys,

I'm new in CI/CD and not-so-experienced in Docker. Right now I have my Django project deployed on DigitalOcean droplet and every time new code is pushed to GitHub, after GitHub action that runs tests automatically, I need to deploy the project manually.

I'm trying to figure out how to make this flow automatic.

This is what I want:

1. push to master (manually)
2. run tests on master (auto)
3. automatically deploy app (auto) if tests passed

I'm considering DigitalOcean Apps platform but the code would be deployed even before the tests passed.

I'm also considering Dockerizing the app but I'm not sure how that would help.

&#x200B;

Can you give me some advice? How would you do that?

&#x200B;

Thanks

/r/django
https://redd.it/xecxo5
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!

This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.

/r/Python
https://redd.it/xehfdb
Deployment - After setting up Gunicorn, Nginx and turn DEBUG = False, how do you update your code?

Is this done through your VPS service (digitalocean, vultr, aws, etc.) ? I am still in my local environment and I have a self-signed HTTPS cert set up so I can "see" what my project will look like without running Django's built-in server. Everything looks good but I wanted to change a couple of things (css, html in the templates, and some of my backend logic in the views.py) but none of my changes have taken effect.

I have:

cleared my browsers cache, restarted Gunicorn and Nginx service, none of it worked. It's almost as if Gunicorn and Nginx have a snapshot of my web app and cannot see any updates that I make.

Any help would be greatly appreciated.

/r/django
https://redd.it/xero8v