Hi
There is a list variable in Python
a=[1, 2, 3....]
I would like to save it as a csv file.
First, I would like to convert it to a variable in this form
b=['1', '2', '3'....]
Then, save it as a CSV file.
What is the code?
There is a simple way to strore and read variables to and from a CSV file in Python:
import numpy as np
np.savetxt('fname.csv', variable, delimiter=',', fmt='%d')
variable = np.loadtxt('fname.csv', delimiter=',')
The above should handle the variable as integers whether 1D or 2D. But if you want to include the quotes in the CSV file itself, then the following code would prove useful (for 1D):
ar = [ ]
for x in a:
ar.append('\''+str(x)+'\'')
np.savetxt('fname.csv', ar, delimiter=',', fmt='%s')
10 November 2016 4,839 2 View
Hi, I need PCA (principle component analysis) code for classification. I would like to use it for fault diagnosis. Thus, the problem is multi-class not just binary-class. I would be grateful if...
05 June 2015 805 1 View
11 December 2014 7,132 7 View
10 November 2014 5,321 0 View
The main idea is to use multivariable time series (as observations) to predict a state variable (one dimension). Please find the attachments. For example time series mm (4 variables and 200...
09 October 2014 6,664 2 View
08 September 2014 4,165 9 View
For a classification problem, consider two steps: training and testing.Assume that the Bayesian network classifier is required to be designed based on data.At first, uniform distribution is...
07 August 2014 8,749 4 View
In addition to mean and variance, what statistics can I use to for discrimination of two signals? I want to determine which signals are more similar to each other and which signals are too different
07 August 2014 7,480 18 View
07 August 2014 4,945 10 View
Naive Bayesian classifier have just two layers, one for Faults and the other for Symptoms. But, some researcher use Bayesian Network for classification such as the attachment. On the other hand,...
07 August 2014 9,188 6 View
Hello all, In SPSS I am going to code 2 open-ended questions. I have already read all the answers and I made a list of the most important categories to which I can code the answers. This question...
02 March 2021 1,757 4 View
Hi, I am trying to construct a multi-layer fibril structure from a single layer in PyMol by translating the layer along the fibril axis. For now, I am able to use the Translate command in PyMol...
02 March 2021 4,569 4 View
I want to do a parameter study of a aixsymmetric cylinder in Abaqus. I want to create several jobs where I get the stresses for 3 different points in my model. These points are defined. I wrote a...
01 March 2021 10,078 1 View
Which is suitable for use with Python? MySQL or SQL Server? What is your suggestion?
01 March 2021 3,422 3 View
The following code (see 1st 2 images attached) is used to produce PID controller values that are designed to control the system (G). The code finds the PID controller values (noted as k) by using...
28 February 2021 6,560 14 View
Please, if Gaussian Parameter optimization is possible in this code structure
28 February 2021 278 3 View
I wanted to add an extra parameter to the existing Johnson cook equation in the ABAQUS simulation. How to add those extra parameters. Ref: A modified Johnson-Cook material model with strain...
28 February 2021 4,841 3 View
I am working on modeling and simulation of biomecanical material behaviour, I have succeded on simulating skin using anisotropic hyperelastic material, on APDL and in our lab's finite element...
28 February 2021 552 3 View
System Description Cuda 11.2 GeForce GTX 1080ti tensorflow version 2.4.1 keras version 2.2.0 python version 3.8 I was getting the below error when I try to run my code on the...
25 February 2021 6,673 2 View
Hello, As part of simulation of gases mixture and water, I need to calculate viscosity of the fluid components and I am using relationships proposed by Chung et al. (1988). The irony is while I...
25 February 2021 8,053 5 View