Python Definition and 655 Threads
-
Python Python troubles- says I'm using a string in arithmetic
Homework Statement I'm making a program to display what I have posted in the image and my program needs to look just like it. The idea is to have an employee enter information such as their pay and hours worked. Then taxes get calculated and it shows a net amount that the employee has made for...- opus
- Thread
- Arithmetic Python String
- Replies: 8
- Forum: Programming and Computer Science
-
M
How to plot timestamps within a row?
i have a dataset that has the timestamp data within each row and I am trying to plot the values to see the distribution but have no idea how to do it if the data is presented this way as attached. any ideas? thanks- msn009
- Thread
- Plot Python Row
- Replies: 7
- Forum: Programming and Computer Science
-
Converting PyGame 2 axis joystick float to 360 angle
I would like to convert my joystick's two axis float (horizontal and vertical) to a 360 angle that can be used to set a players direction in my game. From my research, I've found the best route to take is using Atan2. Variables: self.rot = 0 horaxis = joy1.get_axis(0) veraxis = joy1.get_axis(1)...- archieab
- Thread
- 360 degrees Angle Axis Float Python
- Replies: 2
- Forum: Programming and Computer Science
-
M
Python How to calculate rows where it has values in at least 3 columns
I am trying to count number of rows that has values in at least 3 columns so the output based on the image shared should be 4. I tried using the code below but it is resulting in the same shape as the whole table which is 7. counts = df[(df[['a', 'b', 'c', 'd]] != 'no_label').count(axis=1) >= 3]- msn009
- Thread
- Columns Python
- Replies: 8
- Forum: Programming and Computer Science
-
M
Python Python not recognizing MAX value in a list
i have a value that is generated as the max value for example from this list [0.6000001, 0.3, 0.3, 0.4] clearly the maximum value is 0.6000001 but python does not seem to be able to recognize this value as the maximum. i have tried so many ways to solve it but to no avail. even when changing...- msn009
- Thread
- List Max Python Value
- Replies: 9
- Forum: Programming and Computer Science
-
M
Python How to check that none of the values are equal?
the code below intends to take the maximum value that is calculated for each of the variable but after the max value is obtained I am not sure how to ensure there are no 2 or more values are the same in the if else loop as if 'a' has the max value of 3 and 'b' also has the max value of 3 then...- msn009
- Thread
- Python
- Replies: 17
- Forum: Programming and Computer Science
-
M
Python Problem with appending a dataframe after a loop
I am iterating over 2 variables below and after the calculation are done, i'd like to append the dataframe to add the rows after each iteration, but what is happening now is that the row is getting replaced instead of getting added. pre = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] post = [0, 1, 2, 3, 4...- msn009
- Thread
- Loop Python
- Replies: 9
- Forum: Programming and Computer Science
-
M
Python How to compute the percentage of values based on multiple columns
I have a dataframe as shown in the picture and what I am trying to do is to calculate the number of occurrences based on the values in 2 columns and then calculate the percentage of the occurrences. I have tried the following code but it gives me a zero value in the end and i don't know why...- msn009
- Thread
- Columns Multiple Python
- Replies: 2
- Forum: Programming and Computer Science
-
M
Python How to create a Multi-index dataframe
I would like to generate a multi index dataframe that looks like the image attached. how do i do this in python? I tried this approach but it doesn't give me the output as expected: https://stackoverflow.com/questions/28289440/creating-an-empty-multiindex- msn009
- Thread
- Python
- Replies: 1
- Forum: Programming and Computer Science
-
M
Python How to convert tuple values to strings?
i have a column in a dataframe that contains values in the form or tuples (example: ('A',) ) and I want to convert these values to string format so that ('A',) becomes 'A' How do I do this in python for a dataframe? Thanks.- msn009
- Thread
- Convert Python Strings
- Replies: 3
- Forum: Programming and Computer Science
-
M
How to compute distance of points to a line?
I have computed a line from point A to point B by just subtracting the coordinates as below: line = np.array (x2-x1, y2-y1) I am not sure if I need to form the formula for this line first by computing the slope and intercept but I continued my code as below, slope being m and b being the...- msn009
- Thread
- Geometry Line Points Python
- Replies: 6
- Forum: Programming and Computer Science
-
M
Python How to correctly append a Dataframe?
I have code snippet as below and when i run it, the dataframe seems to append after every loop and does not add the previous row into the frame, so at each time only one row is populated into the new dataframe. How do I ensure that the append function adds the previous row as well...- msn009
- Thread
- Python
- Replies: 5
- Forum: Programming and Computer Science
-
M
MATLAB Switched from win10 and MATLAB to ubuntu and python"q"
Hi, I felt like I have to learn more than one coding language, and wanted to strengthen my coding skills in general. I am good with Relap5 but I want to learn OpenFoam. is what I did logical and going to be worth the pain ? also I only have the Relap5 version of a windows ,is it possible to run...- madhisoka
- Thread
- Cfd Matlab Python Simulation Ubuntu
- Replies: 1
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
A
Python How to solve this electrostatic potential integral equation with Python
Hi! I would like solve this kind of relation: \phi = \int_0^r \phi (r') 4 \pi r'dr' But I don't know how to proceed... Can you advise me ? Thank's in advance !- Ado
- Thread
- Electrostatic Electrostatic potential Integral Integral equation Potential Python
- Replies: 3
- Forum: Programming and Computer Science
-
E
Python Numerical Integration in Python
I want to find the numerical solution to the following nested integral in Python \frac{K!}{(K-M)!}\int_{x_1=0}^{y}\int_{x_{2}=x_1}^{\max(x_1,\,y-x_1)}\cdots \int_{x_M=x_{M-1}}^{\max(x_{M-1},\,y-\sum_{m=1}^{M-1}x_m)} \frac{1}{(1+x_M)^{K-M+2}}\prod_{m=1}^{M-1}...- EngWiPy
- Thread
- Integration Numerical Numerical integration Python
- Replies: 50
- Forum: Programming and Computer Science
-
S
Dealing with 1000 digit numbers
Hi, Mostly i work with Octave / Matlab but i am trying to get into python also. Lately i have a couple problems where my numbers can't be represented in binary64 or float64 default format because they exceed the max of 1.8x10^308. Is there a common way people deal with this (without toolkits)...- Snowmachine
- Thread
- Large numbers Matlab Numbers Precision Python
- Replies: 5
- Forum: Programming and Computer Science
-
J
Python Python programming on Pythonanywhere
Hi all; I've already posted to P_Anywhere's site but... I'm trying to run a script that needs a data file piped to it. Now P_ Anywhere gives you a resident directory and mine contains the program and the data file. Sooo... bonds.py ethane.xyz maybe? Nah. Doesn't like that. But! I did get it to...- jbowers9
- Thread
- Programming Python
- Replies: 7
- Forum: Programming and Computer Science
-
N
Python Unitary transformation using Python
I would like to ask about unitary transformation. UA(IV) UB*UA(IV) UAT(UB*UA(IV))=UB(IV) UB(IV)*(X) IVT(UB(IV)*(X))=UB(X) UBT*UB(X)=X From the information above, UAT,IVT and UBT are the transpose of the complex conjugate. The aim of this code is to get the value of X in the step 4. This is...- Nur Ziadah
- Thread
- Complex conjugate Matrix Python Transformation Unitary transformation
- Replies: 7
- Forum: Programming and Computer Science
-
Python Why Python IDLE is faster than Spyder or Jupyter notebook
I defined a simple prime function and then I append each number to an array up to 1 million and then later 2 million. In both cases, Python IDLE gives me the answer in 4 and 9 seconds respectively, but Spyder and Jupyter Notebook gave me in 12 and 24 seconds. I wonder why this happened. The time...- Arman777
- Thread
- Python
- Replies: 5
- Forum: Programming and Computer Science
-
Learning back-end development with Flask
Hi I want to learn and understand web development, and just knowing what to do is not enough for me; I, to the extent it is possible, want to know how the web works. So, if I develop a web app or website with Flask, I want to know what is going on under the hood (it's just how my head works...- Avatrin
- Thread
- flask Python Web
- Replies: 4
- Forum: Programming and Computer Science
-
Python Recommended Python Books for Beginner Programmers
Hey all, I think most of you know me and probably this question will sound silly but anyways, I am learning python over a 3 month now and The course in the school is over and there will no other course. I want to learn more and is there any source you can recommend me. What I know: 1-I know...- Arman777
- Thread
- Books Python
- Replies: 17
- Forum: Programming and Computer Science
-
R
How Can a Mathematics Major Like Reid Benefit from Joining a Science Forum?
Hello members of PF, my name is Reid Honeycutt. I am a mathematics major at American River College, Sacramento. My mathematical interests are primarily in the areas of algebra and logic. I also love physics and materials science, economics, and programming in python. My motivation in joining...- ReidHoneycutt
- Thread
- algebra python
- Replies: 1
- Forum: New Member Introductions
-
M
Coding a numerical approximation for a damped pendulum
Hi there. I have a question about the damped pendulum. I am working on an exercise where I have already numerically approximated the solution for a simple pendulum without dampening. Now, the excercise says that I can simply change the code of this simple situation to describe a pendulum with...- Marchionni
- Thread
- Approximation Coding Damped Euler method Numerical Numerical approximation Pendulum Physics Python
- Replies: 6
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
J
Python How can numpy.dot() be used in Python to solve Markov chain Monte Carlo methods?
Homework Statement I'm taking an online course in Stat. Mech. and we're working on Markov chain Monte Carlo methods. One of the programs supplied uses the following: Mentor note: Added code tags import numpy neighbor = [[1, 3, 0, 0], [2, 4, 0, 1], [2, 5, 1, 2], [4, 6, 3, 0], [5...- jbowers9
- Thread
- Python
- Replies: 6
- Forum: Programming and Computer Science
-
Python How can I create vector images with Python for laser cutting?
Hi I wish to use Python to create art which can be exported as dxf files for use with laser cutters.While Processing is available for Python, it only creates raster images. What are my options if I want to create vector images? This may be the wrong forum for this question... If it is, where...- Avatrin
- Thread
- files Python Vector
- Replies: 4
- Forum: Programming and Computer Science
-
I How Can I Accurately Fit an Airy Distribution Over Noisy Resonance Data?
Hi all, I performed a resonance experiment over the past two weeks, in which I collected the intensity of a Fabry-Perot cavity whilst adjusting the mirror distance with a piezo-element (the specific setup of the experiment is fairly detached from the question I will ask). My raw data is...- MatthijsRog
- Thread
- Curve Data Experiment Fitting Noise Python Signal
- Replies: 9
- Forum: Other Physics Topics
-
G
Python Practicing Python and R at the same time
Hello, I've learned some of the basics of python through the sololearn Python 3 course (I also started the first week of the MIT Intro to computer science and programming on edx.org, but I found it beyond beginner level and decided to go through the sololearn Python 3 first). My company...- geologist
- Thread
- Python Time
- Replies: 6
- Forum: Programming and Computer Science
-
A
New member and enthusiast to share my experience and learn
hello all i am a new member on Physics Forum i am a last year master student in fundamental physics ( again ) and also have done a master in condense mater and nano-science i worked on noble solid /amorphous interface in my first master internship ( DFT and ab initio molecular dynamic using...- aymalmknn
- Thread
- Condensed matter Density functional theory Fortran90 Python
- Replies: 1
- Forum: New Member Introductions
-
Python Why Does My VPython Moon Orbit Simulation Not Maintain a Circular Path?
Code: https://pastebin.com/5LajNBpj So I was messing with VPython, trying to create an Earth-Moon System. I got the actual gravity to work, and can create some nice ellipical orbits. However I run into trouble trying to make the actual (almost) circular orbit of the moon. I know that the...- CrosisBH
- Thread
- Newtonian gravity Orbit Physics Python Simulator
- Replies: 10
- Forum: Programming and Computer Science
-
A
Python Create a sign-out sheet in Python
Hello everyone, I am trying to create a sign out sheet as if I am a teacher and its so then people can sign out electronically. I know very little python and I have googled most things. I have never worked with a text file before. I am trying to make so it will ask my name, destination, and time...- Adam Kohnle
- Thread
- Python
- Replies: 15
- Forum: Programming and Computer Science
-
MATLAB How can I run Python by getting values from Matlab
I have a python script for which the input data are coming from Matlab. I have tried to use pymatlab, but it is failing. Can anyone suggest any other method?- Nikhil N
- Thread
- Matlab Matlab code Python
- Replies: 3
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
C
Python Polynomial expansion from Python to Mathematica
Hi everybody. In Python there is a library called chaospy. One useful command is cp.orth_ttr which generates a polynomial expansion, e. g. a series of orthogonal polynomials or orders zero, one, two... for a random variable e.g normal, uniform... For more information see...- confused_engineer
- Thread
- Expansion Mathematica Polynomial Python
- Replies: 1
- Forum: Programming and Computer Science
-
Python Interesting article how to use Pandas with Excel sheets
I came across this article about using Pandas in Python to read in a multi-tab spreadsheet to Python, and work with the data then write back to an Excel spreadsheet...- scottdave
- Thread
- article Data analysis Excel Interesting Python
- Replies: 1
- Forum: Programming and Computer Science
-
C
Python Weights and interpolation -- Replicating Python code with hand calculations
Hello everyone. I have a Python code which calculates, given a continuos uniform random variable U(-1,1), the order of a interpolation polynomial and a set of points the evolution of a function of this random variable. i.e. v0 = cp.Uniform(-1,1) t = np.linspace(0, 10, 10) order=1 . . . plt.plot...- confused_engineer
- Thread
- Calculations Code hand Interpolation Python
- Replies: 6
- Forum: Programming and Computer Science
-
C
Python How do I fix this galactic source analysis using python?
Homework Statement This is related to Astronomy & python . I am trying free-up sources on TS map on a galactic source with python script. But when I run the script, at the end of the process, I get the following run time error. Traceback (most recent call last): File "find_new_sources.py"...- Carphysics
- Thread
- Analysis Python Source
- Replies: 1
- Forum: Programming and Computer Science
-
M
Numerically find the energy of the delta-well's bound state
I'm working on an assignment where I'm required to numerically find the energy of a delta-potential's bound state. To do this, we've converted the time-independent schrödinger equation to an eigenvalue problem with E the eigen value, ψ the eigen vector and H a matrix as follows: with ##t =...- Muizz
- Thread
- Bound Bound state Delta function potential Energy Numerical approximation Python Quantum mechahnics State
- Replies: 4
- Forum: Advanced Physics Homework Help
-
S
Python Porting Python Code to Fortran for Parallel Computing
I have a simulation that involves a lot of dense linear algebra with a lot of complex arrays, that was written in python's numpy and then sped up with cython. Unfortunately I'm stuck with python's GIL (global interpreter lock), which prevents the use of numpy with multi-threaded code. I'm...- SevenThunders
- Thread
- Code Computing Fortran Parallel Python
- Replies: 14
- Forum: Programming and Computer Science
-
Python What's wrong with my bisection method code?
Hello, I am assigned to write a code using bisection method (aka binary search method) The equation is 10sin(x) - x^3 - N where N = 1,2,3,4,5,6,7 My code is from math import sin def neg(a, b): return a*b> 0 def bisectx(funcx, lowx, highx,n): assert not neg(funcx(lowx,n), funcx(highx,n))...- Hi Im Paul
- Thread
- Bisection method Code Method Physcis Programming Python
- Replies: 11
- Forum: Programming and Computer Science
-
C
MATLAB Help: Convert Matlab to Python code
I'm working on a convolutional neural network project that classifies histopathological images of breast tumors. All my code is in python. Part of the image preprocessing involves appearance normalisation to account for the variation in histological staining. The only code for the preprocessing...- CrazyNeutrino
- Thread
- Code Convert Matlab Python
- Replies: 17
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
E
Python Understand Binning Data in Python
Hello, I was reading an example on binning data, where a continuous variable is transformed into a categorical variable. The dataframe name is df, and the continuous variable's column's name is 'horsepower'. We would like to transform the continuous variable feature into a categorical feature...- EngWiPy
- Thread
- Data Python
- Replies: 5
- Forum: Programming and Computer Science
-
E
Python Good books to learn machine learning using Python
Hello, I am new to both Python and machine learning. I am trying to learn by reading books on machine learning using Python. I started with this book. I could manage the first 3 chapters (although I had to dissect the codes on Github because not all the codes are included and explained in the...- EngWiPy
- Thread
- Books Machine Machine learning Python
- Replies: 4
- Forum: Programming and Computer Science
-
D
How do I save a file in Sublime to a specific folder?
Hi guys. Just wanted to see if I could get a point on this problem I'm having. I'm using a book to learn Python3 and I'm using SublimeText as an editor. The book initially told me to configure Sublime for Python3 by typing this into a blank Sublime file: { "cmd": ["/usr/local/bin/python3"...- DS2C
- Thread
- Initial Python
- Replies: 11
- Forum: Programming and Computer Science
-
Python What does this Python program do?
Can someone tell me what does this Python program do? :wink: s = 's = %r\nprint(s%%s)' print(s%s) Mentor: add html code tags- Demystifier
- Thread
- Program Python
- Replies: 4
- Forum: Programming and Computer Science
-
Python Removing previously plotted points on scatter plot; python
Homework Statement I'm plotting moving particles and I need a way to refresh the graph space with every loop. Meaning I want the points to NOT leave a trail of other points behind them . Basically I want to get rid of the old points as I plot new ones. Homework Equations N\A The Attempt at a...- Morbidly_Green
- Thread
- Matplotlib Plot Plotting Points Python
- Replies: 2
- Forum: Programming and Computer Science
-
M
Python Why Isn't QPushButton Triggering Method in PyQt5?
I'm new to this forum, as well as Python, so bare with me, won't you:) Ok, so I have this GUI written in python and utilizing PYQT5. I have a functioning version, but I now want to add a QpushButton that executes a method called add_Bladebox. This method adds a doublespinbox to the gui. The...- Mckamar
- Thread
- Gui Python
- Replies: 2
- Forum: Programming and Computer Science
-
X
How to Calculate Correlation Time Using Numpy for Monte Carlo Simulations?
I'm creating a Monte Carlo simulation of the 2D Ising Model for a graduate course in computational materials science. Part of the assignment is to calculate the uncertainty in the calculation of the average magnetization per spin. To do so, we are told to find the correlation time for our data...- xperrylinn
- Thread
- monte carlo numpy python
- Replies: 1
- Forum: Engineering and Comp Sci Homework Help
-
J
Python How can I integrate sinusoids in python code using FFT?
Hello, Thank you for taking time to read my post. I have a discrete set of data points that represent an acceleration signal. I want to take the integral of this set of points twice so as to get a function which represents the position over time. To accomplish this, I have taken the FFT of the...- jameslat
- Thread
- Code Fft Python
- Replies: 3
- Forum: Programming and Computer Science
-
S
Python Discrete Fourier Transform in Python
Homework Statement I need to calculate the derivative of a function using discrete Fourier transform (DFT). Below is a simplified version of my code (just for sin function) in python Homework Equations from __future__ import division import numpy as np from pylab import * pi = np.pi def...- Silviu
- Thread
- Discrete Discrete fourier transform Fourier Fourier transform Python Transform
- Replies: 7
- Forum: Programming and Computer Science
-
Python User-Defined Function in Python
Homework Statement So currently I'm working with user-defined functions. Initially, the code inside the user-defined function worked but when I attempted to change it into a user-defined function, it produces incorrect values. Homework Equations No need for any equations The Attempt at a...- K_Physics
- Thread
- Function Python
- Replies: 11
- Forum: Programming and Computer Science
-
Python Working with PNG images in Python
Hi I have to run a few algorithms using Python on PNG-images. However, I also know that PNG is compressed... How do I do this? I need to learn the following: 1: Extracting the RGB information about the pixels. 2: Isolating parts of the image (for example, importing an image and only working on...- Avatrin
- Thread
- Image processing Images Python
- Replies: 13
- Forum: Programming and Computer Science