Comments (2)
In my mind, this is a behavior that was made by pandas
so I hesitate to overload it to change it. For example, this method also doesn't differentiate between np.int64
and pd.Int64Dtype
(the nullable pandas int64 implementation):
In [17]: df = pd.DataFrame(np.arange(12).reshape(3, 4),
...: columns=['A', 'B', 'C', 'D'])
...: df["A"] = df["A"].astype(pd.Int64Dtype())
In [18]: df.dtypes
Out[18]:
A Int64 <----- Note capitalization
B int64
C int64
D int64
dtype: object
In [19]: df.select_dtypes(pd.Int64Dtype())
Out[19]:
A B C D
0 0 1 2 3
1 4 5 6 7
2 8 9 10 11
I do agree that their documentation doesn't make it clear that this operates to return columns based on the underlying numpy dtype though. It is always possible to get this behavior with a list comprehension, so if we do want this sort of method, I would rather implement it as a custom DataSet
method rather than overload the DataFrame
one. Something like this, but with added support to handle inputting the dtype as str or object:
def select_mtzdtype(self, dtype):
return self[[k for k in self if isinstance(self.dtypes[k], dtype)]]
from reciprocalspaceship.
I'm totally happy with your proposed solution.
from reciprocalspaceship.
Related Issues (20)
- Resolving indexing ambiguities when comparing datasets HOT 12
- Add `sample_rate` or `resolution_cutoff` options for `to_reciprocalgrid` HOT 5
- rs.DataSet.assign_resolution_bins ought to return bin edges HOT 1
- Cannot unstack_anomalous with other columns in index
- groupby apply drops cell and spacegroup HOT 2
- `stack_anomalous` inside `groupby` breaks `as_index=False` HOT 1
- Unstack anomalous taking into account Careless repeats HOT 10
- rs.utils.asu.in_asu() does not use the 'anomalous ASU' for stacked anomalous data. HOT 1
- function for cif file IO and possible support for multi-dataset files HOT 3
- `hkl_to_asu` does not annotate M/ISYM field correctly HOT 2
- support for read_precognition() for hkl without anomalous columns HOT 6
- unstack_anomalous makes data that phenix cannot interpret HOT 3
- API reference website display
- Return keys of dictionary in crystfel.py HOT 6
- add_rfree() does not consider Friedel mates HOT 2
- `rs.DataSet.reset_index()` call signature does not match pandas >1.5 HOT 1
- Used pandas.core.ops attribute does not appear to exist HOT 4
- A `rs.cifdump` utility?
- No documentation of CrystFEL columns HOT 1
- mean_intensity_by_miller_index should use a grid HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reciprocalspaceship.