Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to do downsampling in python

import xarray as xr
import numpy as np
import matplotlib.pyplot as plt

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15,5))

# Create a 10x10 array of random numbers
a = xr.DataArray(np.random.rand(10,10)*100, dims=['x', 'y'])

# "Downscale" the array, mean of blocks of size (2x2)
b = a.coarsen(x=2, y=2).mean()

# "Downscale" the array, mean of blocks of size (5x5)
c = a.coarsen(x=5, y=5).mean()

# Plot and cosmetics
a.plot(ax=ax1)
ax1.set_title("Full Data")

b.plot(ax=ax2)
ax2.set_title("mean of (2x2) boxes")

c.plot(ax=ax3)
ax3.set_title("mean of (5x5) boxes")
Comment

python downsampling

df_ham_downsampled = df_ham.sample(df_spam.shape[0])
Comment

PREVIOUS NEXT
Code Example
Python :: standard destructuring assignments in python 
Python :: coin flip numpy 
Python :: Python - Cómo Jugar archivo Mp3 
Python :: Python - Comment préparer la capitalisation 
Python :: running code once in a while loop python 
Python :: how to search for element in list python 
Python :: extract area code from phone number python 
Python :: find las element of array python 
Python :: flask buildspec.yml 
Python :: regex emaple py 
Python :: hack instagram account with python 
Python :: Free the Bunny Prisoners 
Python :: Replace u00a0 
Python :: python how to acquire the html code for a website 
Python :: tar: Exiting with failure status due to previous errors 
Python :: check version of various pkgs 
Python :: how to create a login page in python 
Python :: set defualt to none django 
Python :: How to test if a webpage is an image python requests 
Python :: computecost pyspark 
Python :: how to concatenate all list inside list 
Python :: python image resize 
Python :: get length of a tuple in python 
Python :: python long 
Python :: pandas return indices that match 
Python :: how to save date in cookie Python 
Python :: not mutable data type in python 
Python :: shotgun meanign 
Python :: Random Remarks Example in python 
Python :: python text to speech arabic 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =