dppd 0.26__tar.gz → 0.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dppd
3
- Version: 0.26
3
+ Version: 0.27
4
4
  Summary: A pythonic dplyr clone
5
5
  Home-page: https://github.com/TyberiusPrime/dppd
6
6
  Author: Florian Finkernagel
@@ -1,12 +1,12 @@
1
1
  [metadata]
2
2
  name = dppd
3
3
  description = A pythonic dplyr clone
4
- version = 0.26
4
+ version = 0.27
5
5
  author = Florian Finkernagel
6
- author-email = finkernagel@imt.uni-marburg.de
6
+ author_email = finkernagel@imt.uni-marburg.de
7
7
  license = mit
8
8
  url = https://github.com/TyberiusPrime/dppd
9
- long-description = file: README.md
9
+ long_description = file: README.md
10
10
  long_description_content_type = text/markdown
11
11
  platforms = any
12
12
  classifiers =
@@ -4,6 +4,6 @@ from .base import dppd, register_verb, register_type_methods_as_verbs
4
4
  from . import single_verbs # noqa:F401
5
5
  from . import non_df_verbs # noqa:F401
6
6
 
7
- __version__ = "0.26"
7
+ __version__ = "0.27"
8
8
 
9
9
  __all_ = [dppd, register_verb, register_type_methods_as_verbs, __version__]
@@ -939,7 +939,7 @@ def to_frame_dict(d, **kwargs):
939
939
 
940
940
 
941
941
  @register_verb("norm_0_to_1", types=pd.DataFrame)
942
- def norm_0_to_1(df, axis=1):
942
+ def norm_0_to_1(df, axis=1, keep_nan=False):
943
943
  """Normalize a (numeric) data frame so that
944
944
  it goes from 0 to 1 in each row (axis=1) or column (axis=0)
945
945
  Usefully for PCA, correlation, etc. because then
@@ -951,7 +951,9 @@ def norm_0_to_1(df, axis=1):
951
951
  a1 = 0
952
952
  a2 = 1
953
953
  df_normed = df.sub(df.min(axis=a1), axis=a2)
954
- df_normed = df.div(df.max(axis=a1), axis=a2)
954
+ df_normed = df.div(df_normed.max(axis=a1), axis=a2)
955
+ if not keep_nan:
956
+ df_normed = df_normed[~pd.isnull(df_normed).any(axis=1)]
955
957
  return df_normed
956
958
 
957
959
 
@@ -1000,7 +1002,12 @@ def pca_dataframe(df, whiten=False, random_state=None, n_components=2):
1000
1002
 
1001
1003
  p = PCA(n_components=n_components, whiten=whiten, random_state=random_state)
1002
1004
  df_fit = pd.DataFrame(p.fit_transform(df))
1003
- df_fit.columns = ["1st", "2nd"]
1005
+ cols = ["1st", "2nd"]
1006
+ if n_components > 2:
1007
+ cols.append('3rd')
1008
+ for ii in range(3, n_components):
1009
+ cols.append(f"{ii+1}th")
1010
+ df_fit.columns = cols
1004
1011
  df_fit.index = df.index
1005
1012
  df_fit.index.name = "sample"
1006
1013
  df_fit = df_fit.reset_index()
@@ -1012,7 +1019,6 @@ def pca_dataframe(df, whiten=False, random_state=None, n_components=2):
1012
1019
 
1013
1020
  @register_verb("insert", types=pd.DataFrame, ignore_redefine=True)
1014
1021
  def insert_return_self(df, loc, column, value, **kwargs):
1015
- """DataFrame.insert, but return self.
1016
- """
1022
+ """DataFrame.insert, but return self."""
1017
1023
  df.insert(loc, column, value, **kwargs)
1018
1024
  return df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dppd
3
- Version: 0.26
3
+ Version: 0.27
4
4
  Summary: A pythonic dplyr clone
5
5
  Home-page: https://github.com/TyberiusPrime/dppd
6
6
  Author: Florian Finkernagel
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes