What do you want to save?
Add Code snippet
New code examples
-
Python 2021-09-28 13:13:04
save array as npz python
# save numpy array as npy file from numpy import asarray from numpy import save # define data data = asarray([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) # save to npy file save('data.npy', data) # load numpy array from npy file from numpy import load # load array ... Add solution -
Python 2021-09-21 17:03:04
dataframe object to numpy array
import pandas as pd #initialize a dataframe df = pd.DataFrame( [[21, 72, 67], [23, 78, 69], [32, 74, 56], [52, 54, 76]], columns=['a', 'b', 'c']) #convert dataframe to numpy array arr = df.to_numpy() print('\nNumpy Array\n----------\n', arr) Add solution -
Python 2021-09-12 01:20:01
python when to use pandas series, numpy ndarrays or simply python dictionaries
# A useful rule of thumb is to use the simplest data structure that still # satisfies your needs. If we rank the data structures from most simple # to least simple, it usually ends up like this: 1. Dictionaries / lists 2. Numpy arrays 3. Pandas series / ... Add solution -
Python 2021-09-06 05:46:01
python mean and standard deviation of list
import numpy as np # list containing numbers only l = [1.8, 2, 1.2, 1.5, 1.6, 2.1, 2.8] # switch to numpy array v = np.array(l) mean = v.mean() # average ~ 1.86 std = v.std() # stadrad deviation (square root of variance) ~ 0.48 Add solution -
Python 2021-09-04 08:51:02
euclidean distance python 3 variables
# Python code to find Euclidean distance # using sum() and square() import numpy as np # intializing points in # numpy arrays point1 = np.array((1, 2, 3)) point2 = np.array((1, 1, 1)) # finding sum of squares sum_sq = np.sum(np.square(po... Add solution -
Other 2021-08-29 20:06:02
AttributeError: 'numpy.ndarray' object has no attribute 'value_counts'
# Counting values from a numpy array import numpy as np a = np.array([0, 3, 0, 1, 0, 1, 2, 1, 0, 0, 0, 0, 1, 3, 4]) unique, counts = np.unique(a, return_counts=True) dict(zip(unique, counts)) output: {0: 7, 1: 4, 2: 1, 3: 2, 4: 1} # Counting values f... Add solution -
Python 2021-08-28 02:15:02
gaussian elimination python without library
# Importing NumPy Library import numpy as np import sys # Reading number of unknowns n = int(input('Enter number of unknowns: ')) # Making numpy array of n x n+1 size and initializing # to zero for storing augmented matrix a = np.zeros((n,n+1)) # Mak... Add solution
Best helpers
LastTribunal
+5
Pham Van Duc
+5
Ron Wyse
+5
Sanat
+5
JasonTrue
+5
Felix G
+5
Paul Lucas
+5
Sahej Narang
+5
Tachyon
+5
Mrturtle
+5
A.Danesh
+5
Ann
+5
Kristof Tak
+5
TimmyRS
+5