mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add isin function in DataFrame and Series
This commit is contained in:
parent
1427817478
commit
1794f0def1
@ -3513,6 +3513,27 @@ public class DataFrame implements Iterable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether elements in DataFrame are contained in values
|
||||
*
|
||||
* @param values The values
|
||||
* @return DataFrame of booleans indicating if each element is in values
|
||||
*/
|
||||
public DataFrame isIn(List values) {
|
||||
if (this.array2D) {
|
||||
Array a = ArrayMath.inValues((Array) this.data, values);
|
||||
return new DataFrame(a, (Index) this.index.clone(), this.columns.copyAsBoolean());
|
||||
} else {
|
||||
List<Array> arrays = (List<Array>) this.data;
|
||||
List<Array> r = new ArrayList<>();
|
||||
for (Array arr : arrays) {
|
||||
Array a = ArrayMath.inValues(arr, values);
|
||||
r.add(a);
|
||||
}
|
||||
return new DataFrame(r, (Index) this.index.clone(), this.columns.copyAsBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
Object rdata;
|
||||
|
||||
@ -550,6 +550,17 @@ public class Series implements Iterable {
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether elements in Series are contained in values
|
||||
* @param values The values
|
||||
* @return Series of booleans indicating if each element is in values
|
||||
*/
|
||||
public Series isIn(List values) {
|
||||
Array rdata = ArrayMath.inValues(data, values);
|
||||
Series r = new Series(rdata, index, name);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string - head
|
||||
*
|
||||
|
||||
@ -1,32 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\netcdf">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\dataframe">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\text"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\bar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar\cinrad"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe\series"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\bar\map_bar_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\netcdf\test_read.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\cinrad\test_read_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\cinrad\radar_cma_base_cappi.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\isin_1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_grid.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\bar\map_bar_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\netcdf\test_read.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\cinrad\test_read_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\cinrad\radar_cma_base_cappi.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\isin_1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -34,5 +34,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1407,851"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1354,829"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -1040,6 +1040,18 @@ class DataFrame(object):
|
||||
"""
|
||||
return DataFrame(dataframe=self._dataframe.stdDev())
|
||||
|
||||
def isin(self, values):
|
||||
"""
|
||||
Whether elements in DataFrame are contained in values.
|
||||
|
||||
Return a boolean DataFrame showing whether each element in the DataFrame matches an element in the passed
|
||||
sequence of values exactly.
|
||||
|
||||
:param values: (*list*) The sequence of values to test.
|
||||
:return: (*DataFrame*) DataFrame of booleans indicating if each element is in values.
|
||||
"""
|
||||
return DataFrame(dataframe=self._dataframe.isIn(values))
|
||||
|
||||
@classmethod
|
||||
def read_table(cls, filepath, **kwargs):
|
||||
"""
|
||||
|
||||
Binary file not shown.
@ -408,6 +408,19 @@ class Series(object):
|
||||
else:
|
||||
return r
|
||||
|
||||
def isin(self, values):
|
||||
"""
|
||||
Whether elements in Series are contained in values.
|
||||
|
||||
Return a boolean Series showing whether each element in the Series matches an element in the passed
|
||||
sequence of values exactly.
|
||||
|
||||
:param values: (*list*) The sequence of values to test.
|
||||
:return: (*Series*) Series of booleans indicating if each element is in values.
|
||||
"""
|
||||
r = self._series.isIn(values)
|
||||
return Series(series=r)
|
||||
|
||||
def groupby(self, by=None):
|
||||
"""
|
||||
Group Series.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user