Questions tagged [python]

Questions about interfacing with, or features inspired or demonstrated by Python--a programming language featuring a dynamic type system, automatic memory management, and a comprehensive standard library.

Filter by
Sorted by
Tagged with
6
votes
2answers
566 views

Export a 3D array from Mathematica and import it in python as a numpy array

In ...
4
votes
3answers
545 views

Difference between Python and Mathematica for Newton's Algorithm [closed]

I was about to study the roots of the function defined below, using Newton's Method: 9 Exp[-x] Sin[2 π x] - 0.0015 For initial values, I have: ...
3
votes
0answers
119 views

`ExternalEvaluate` for NumPy: passing numpy arrays

As ExternalEvaluate for python has been introduced recently in V11.2, what is the best practice for passing data between Mathematica and NumPy? As by default, the ...
2
votes
0answers
210 views

Mathematica style plotting in Python? [duplicate]

This question has two related parts. I recently started using more python because it is easier to setup remote machines (and cheaper). But I really miss Mathematica's plotting capabilities and syntax. ...
7
votes
0answers
123 views

How to pass in-memory images through ExternalEvaluate?

Version 11.2 has a new import/export format PythonExpression. Unfortunately, it doesn't work out-of-the-box with images: And using the ImageData directly is too slow: Anyhow, I have some image ...
20
votes
1answer
737 views

ExternalEvaluate for Python fails with Import::nopythonevals

I tried using ExternalEvaluate on OS X with Anaconda Python, and every ExternalEvaluate call failed with the ...
4
votes
1answer
192 views

Using virtualenv and ExternalEvaluate

When doing development work with python, it's often recommended that one use virtualenv. It provides an environment separate from one's standard python evaluator. Now that 11.2 has support for simple ...
5
votes
1answer
1k views

Equivalent of “for X in [list]” or “foreach”

In Python, we can evaluate an expression over specific values of x in a list. Example: ...
4
votes
3answers
813 views

run python with package numpy in mathematica

For example, if I have a python script called simple.py contains as simple as a=1 print(a) then ...
1
vote
0answers
78 views

possibility of using `f2py` for interoperability with Fortran

Although interoperability with Fortran could be realised by using LibraryLink (e.g., Linking FORTRAN with Librarylink), the approach is not so straight forward, in ...
4
votes
1answer
543 views

Problem calling Python scripts from Mathematica

so I'm running into a strange problem using Import[] to import the output of a python 3.6 script. I have a script my_script.py ...
0
votes
2answers
649 views

Create smooth colour map from given array for ListPlot3D

I am trying to find the Mathematica equivalent for Python Matplotlib's cmap option, to be used with ListPlot3D[]. Here is the ...
28
votes
2answers
3k views

Exchanging numpy arrays between Python and Mathematica?

I've been using np.savetxt(location, result, delimiter=',') in Python followed by Import[location,"CSV"] in Mathematica. Some of ...
7
votes
1answer
413 views

mathematica's equivalent of python list functionnality

In Python there is a a compact syntax for creating variables that refer to the various list elements. ...
3
votes
1answer
665 views

Python/Numpy array manipulation in Mathematica syntax

As a python programmer, numpy tools usually come to my mind if I want to manipulate arrays (list, matrices, ...). Is there any reference (e.g., dictionary) of how to translate numpy syntax to ...
7
votes
4answers
598 views

Python's “pop” equivalent in Mathematica

I will like to know if there is an equivalent to python's pop method, here is how it's done in Python: ...
5
votes
2answers
542 views

Convert Python math expression form (Sin and Cos) to Python math expression?

I have a really big symbolic output from Python, and it contains Sin and Cos. Now I want to solve it using Mathematica, but the ...
0
votes
1answer
1k views

Help: Shifted columns values of a dataset [closed]

How do i add a new column to a Dataset that is the shifted version of another column with nulls placed in missing places. (just like the function shift in pandas in ...
4
votes
2answers
273 views

How to call Picture Bed API

I want to call this Picture bed API to upload my picture and return its link.I have translated the official instructional the page into English.And there is a example succeed to use it with Python. I ...
4
votes
1answer
461 views

Translating python code to mathematica code

I am working on a program that does some stuff with the collatz conjecture. I originally wrote it in Python as that is the language I am most familiar with: ...
4
votes
0answers
80 views

A general question about integrating MMA objects into a python workflow

I recently built a classifier using the built-in Classify command in MMA v11.01. We are exploring the feasibility of using python-based workflow (to be consistent with our company practice) that would ...
14
votes
1answer
818 views

Mathematica + Pythonika on the Raspberry pi

Due to the high availability of python code for the rpi, I'm trying to call python functions from Mathematica. I know that pythonika works well on OS X, but I can't compile it on the Raspberry pi. ...
3
votes
0answers
112 views

Use Mathematica inside web app?

My python code running in a Flask web application needs to return results from Mathematica, what is the best way to achieve this? Are there any examples of this having been done successfully?
0
votes
0answers
43 views

Someone write Pygments for Mathematica? [duplicate]

Pygments is a python program which highlights source code. See http://pygments.org/languages/. Mathematica is not in the list. Is anyone interested in doing this?
12
votes
2answers
496 views

Is there any PythonForm ? to automate Sin[] to math.sin()? [duplicate]

Sin[] does not exist in Python and while I can do FortranForm and similar things, I do not know of any ...
2
votes
1answer
282 views

I have a communications link failure with JDBC MySQL(Connector/J)

I am unable to connect to my local mysql server using Mathematica. ...
6
votes
2answers
2k views

How to export an output matrix obtained in mathematica to a matrix in python with the correct format?

I have a large sparse matrix as the output and I want to save the output and open it as a matrix in python. The output is a 6000 x 6000 matrix and I don't know how to make changes to the file such ...
2
votes
0answers
147 views

Using a POST request to populate parameters for a CloudObject

I am using python (ver. 2.7) in conjunction with Wolfram Language to create and build strings in a query language syntax. I have a successfully deployed an ...
2
votes
1answer
399 views

Python Convolve2D functionality in Mathematica

I am new to mathematica. I am looking for an alternative for scipy.signal.convolve2d. I did find functions like ListConvolve, ...
4
votes
0answers
92 views

Why do Python modules load differently via Mathematica? [duplicate]

It's a steep learning curve trying to integrate Mathematica with Python's modules/library. I am using a Raspberry Pi 3 with Mathematica's Wolfram command line. I know little about both platforms (so ...
4
votes
0answers
328 views

How to run a Mathematica package (.m) from python?

I am new to Mathematica and I need to interface with a Python code that I have. Basically, I have a Mathematica package (.m) with a bunch of complicated functions. I want to use some code from python ...
1
vote
0answers
129 views

Calling python code on an image directly (without writing to disk / stdin)

I have lots of image processing code written in python and would like to call it from within mathematica. Is there a way to transmit the image data directly like with c++ and LibraryLink? I'd rather ...
1
vote
0answers
256 views

Issue with WSTP

I'm trying to get Pythonika to work once again - with the latest version of the WSTP. The changes required are not many, basically just three: Change ML to WS Change mprep to wsprep Change mcc to ...
1
vote
1answer
356 views

How to visualize .data files? [closed]

I am working with simulation models trying to carrying out some predictions in ocean waves and this stuff. (MITgcm) I am able to run the program and generate hundreds of .data and .meta files, but i ...
5
votes
1answer
2k views

How to continuously run a Python script

I am running this script: script = Import["!python C:\\...python script", "String"]; but I need to run it a few times as it outputs data I need. I run it every ...
31
votes
1answer
5k views

Numerical integration — Mathematica vs Python (w/ Scipy) performance

I'm about to tackle a problem that involves a lot of (multi-dimensional) numerical integrations and also subsequent optimizations, and so I want to make sure at least the integration step is as fast ...
1
vote
2answers
509 views

What can I use as an equivalent of python zip in mathematica inside of Sum[]? [closed]

I want to take two lists of the same length: widths and weights, and sum a function (of 3 variables) over a single index using the elements from both lists that have that index. Then I want to plot ...
31
votes
1answer
2k views

How does Dataset compare to DataFrame in pandas?

Pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with “relational” or “labeled” data. Just like ...
65
votes
8answers
10k views

What are the Wolfram Language's relative strengths for machine learning?

I see a low use of Mathematica in Kaggle competitions. Why would one use the Wolfram Language versus R, Python, or Julia for machine learning? Besides prettier plots and the Manipulate function, ...
15
votes
1answer
2k views

Any solution to transfer data between Python and Mathematica

I think Mathematica handles .mat file not very well, python is pretty good at this kind of jobs. In this site, there are plenty of question related to calling Mathematica from Python, or calling ...
37
votes
3answers
17k views

Mathematica vs. Python - how does Mathematica compare to Python's scientific computing suite?

Python's family of packages for scientific computing has matured rapidly. I can pretty much replicate all of Mathematica's functionalities, but with production level and open-source code using the ...
18
votes
2answers
3k views

Prepare mathematica output to be parsed in Python

I have Mathematica output that I would like to parse in python so I can generate equivalent expressions. So suppose I have the following: ...
8
votes
2answers
10k views

Convert mathematica math expression form to python math expression?

I obtain a raw input form of: ...
34
votes
2answers
3k views

Is there a built-in equivalent to Python's enumerate?

Python's built-in function enumerate takes an iterable over $(a_0, a_1, \dots )$ as argument and returns an iterable over the sequence of pairs $((0, a_0), (1, a_1),...
64
votes
3answers
5k views

Python-style plots in Mathematica

I love making plots in Mathematica. And I love to spend a lot of time making high-quality plots that maximize readability and aesthetics. For most cases, Mathematica can make very beautiful images, ...
-2
votes
1answer
145 views

Recreating in Mathematica a matrix created in Python [closed]

I need to recreate in Mathematica this matrix that I created in Python: ...
0
votes
1answer
130 views

Create an array with certain conditions and use it to fill a matrix [closed]

I am translating my code from Python to Mathematica. Here is a piece of my Python code: ...
3
votes
2answers
403 views

Build mathlink.pyd for Python on windows using Mathematica 10

Evidently, the mathlink Python extension has not been updated for some time. As shown below, it doesn't link to the correct libraries. Also, the API seems to have been updated while the mathlink ...
5
votes
3answers
2k views

How to convert a Mathematica list in a Python list?

I was wondering if you know, how to save a Mathematica list (variable) such that it can be read later in Python. In order words, how to save a variable ...
9
votes
0answers
764 views

How to write markdown with Mathematica? [duplicate]

Usually I typeset with Latex and Compute with Mathematica and then copy the outputs as Latex code and insert them in Latex, so I have to switch between Latex and Mathematica frequently. Thanks to the ...