xarray.Dataset.polyfit not available in xarray v 0.15.1 - version

I am new to python. I updated xarray to 0.15.1 in order to use the new xarray.Dataset.polyfit and xarray.Dataset.polyval function. However these function are not available in my version. What am I doing wrong?
import xarray as xr
xr.__version__
Output is: '0.15.1'
xr.Dataset.polyfit?
Output is: Object 'xr.dataset.polyfit' not found.
Thank you!

polyfit is not released yet in xarray 0.15.1. See
this xarray github issue for more details.

Related

UnicodeDecodeError Sentiment140 Kaggle

I am trying to read the Sentiment140.csv available on Kaggle: https://www.kaggle.com/kazanova/sentiment140
My code is this one:
import pandas as pd
import os
cols = ['sentiment','id','date','query_string','user','text']
BASE_DIR = ''
df = pd.read_csv(os.path.join(BASE_DIR, 'Sentiment140.csv'),header=None, names=cols)
And it gives me this error:
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position
80-81: invalid continuation byte
The things I would like to understand are:
1) How do I solve this issue?
2) Where can I see which type of encoding should I use instead of "utf-8", based on the error?
3) Using other encoding methods will cause me other issues later on?
Thanks in advance
P.s. I am using python3 on a mac
This works:
https://investigate.ai/investigating-sentiment-analysis/cleaning-the-sentiment140-data/
Turns out encoding="latin-1" and you have to specify column names, otherwise it will use the first row as column names. This is how lousy real-world dataset can be haha

How does one call external datasets into scikit-learn?

For example consider this dataset:
(1)
https://archive.ics.uci.edu/ml/machine-learning-databases/annealing/anneal.data
Or
(2)
http://data.worldbank.org/topic
How does one call such external datasets into scikit-learn to do anything with it?
The only kind of dataset calling that I have seen in scikit-learn is through a command like:
from sklearn.datasets import load_digits
digits = load_digits()
You need to learn a little pandas, which is a data frame implementation in python. Then you can do
import pandas
my_data_frame = pandas.read_csv("/path/to/my/data")
To create model matrices from your data frame, I recommend the patsy library, which implements a model specification language, similar to R formulas
import patsy
model_frame = patsy.dmatrix("my_response ~ my_model_fomula", my_data_frame)
then the model frame can be passed in as an X into the various sklearn models.
Simply run the following command and replace the name 'EXTERNALDATASETNAME' with the name of your dataset
import sklearn.datasets
data = sklearn.datasets.fetch_EXTERNALDATASETNAME()

How to export some selected records from SQLFORM.grid as doc or pdf format in web2py

When I click the checkbox before every row, export the selected records as doc or pdf format. How to realize this?
def test():
form=SQLFORM.grid(db.problem,selectable = lambda ids:download(ids)
return dict(form=form)
def export(ids):
if I set csv=True in SQLFORM.grid there are some format while no doc and pdf!
Thanks!
Jian,
Unfortunately, working with .doc, .docx (Microsoft Word) and .pdf isn't as simple as you might think it is.
For Word, you'll need python-docx that can be installed with $ pip install python-docx and you can find the documentation an sample code here.
To create a PDF document, you'll only need to import pyfpdf using from gluon.contrib.fpdf import FPDF, since web2py already comes with it. But, the same case applies here: You'll need to read some documentation and write some code.

cv.Save and cv.Load (array)

I need to save and load an array, but I get this error:
cv.Save('i.xml',i)
TypeError: Cannot identify type of 'structPtr'
This is the code:
import cv
i = [[1,2],[3,4],[5,6],[7,8]]
cv.Save('i.xml',i)
That's because cv.Save needs to receive the object to be stored in the file as an OpenCV object. For example, the following is a minimal workable example that saves a numpy array in a file using cv.Save:
import cv2
import numpy as np
i = np.eye(3)
cv2.cv.Save('i.xml', cv2.cv.fromarray(i))
As you can see here, arrays should be converted back to numpy from OpenCV as well after reading.
Regards.

Getting error while using new JParameter($plugin->params); in joomla 3.0

I have used the following code in joomla 3.0 for getting plugin parameters.
new JParameter($plugin->params);
But I am getting error.
Please any one can help me.
Regards,
Jaylani.
As JParameter was using JRegistry, here is a work around:
$params = new JRegistry();
$params->loadString($module->params);
$params->get('param_name');
Removed classes
JParameter (use JForm instead or, in most circumstances, JRegistry - for example to retrieve in a component a plugin parameter).
Source
A little late, but for everyone else who stumbles upon this:
Use:
json_decode($plugin->params);
I found this along with lots of other useful informations about the changes in Joomla 3.0 here: techjoomla.com
Try the following instead of JParameter (deprecated class in J3):
jimport('joomla.html.parameter');
$params = new JInput();
$params->get('params');
This might answer your question and solve your issue.
JParameter is deprecated use Registry.
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Registry\Registry;
$plugin = PluginHelper::getPlugin('plg_Type', 'plg_Name');
$plgParams = new Registry($plugin->params);
$param = $plgParams->get('your_param_name', 'default_value')

Resources