Update a DataFrame/Series with the values of another
Project description
pip install a-pandas-ex-df-updater
# Update a DataFrame/Series with the values of another.
from a_pandas_ex_df_updater import pd_add_df_updater
pd_add_df_updater()
df1 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
columns=['a', 'b', 'c'])
df2 = pd.DataFrame(np.array([[11, 2, 3], [4, 55, 6], [7, 8, 9], [17, 2, 93]]),
columns=['a', 'x', 'y'])
df3=df1.ds_update(forupdate=df2,update_existing_values=True, add_new_columns=False,add_new_rows=False)
df1
a b c
0 1 2 3
1 4 5 6
2 7 8 9
df2
a x y
0 11 2 3
1 4 55 6
2 7 8 9
3 17 2 93
df3
a b c
0 11 2 3
1 4 5 6
2 7 8 9
df3=df1.ds_update(forupdate=df2,update_existing_values=True, add_new_columns=True,add_new_rows=False)
df1
a b c
0 1 2 3
1 4 5 6
2 7 8 9
df2
a x y
0 11 2 3
1 4 55 6
2 7 8 9
3 17 2 93
df3
a b c x y
0 11 2 3 2 3
1 4 5 6 55 6
2 7 8 9 8 9
df3=df1.ds_update(forupdate=df2,update_existing_values=True, add_new_columns=True,add_new_rows=True)
df1
a b c
0 1 2 3
1 4 5 6
2 7 8 9
df2
a x y
0 11 2 3
1 4 55 6
2 7 8 9
3 17 2 93
df3
a b c x y
0 11 2.0 3.0 2 3
1 4 5.0 6.0 55 6
2 7 8.0 9.0 8 9
3 17 NaN NaN 2 93
df1.ds_update(forupdate=df2,update_existing_values=False, add_new_columns=True,add_new_rows=True)
df1
a b c
0 1 2 3
1 4 5 6
2 7 8 9
df2
a x y
0 11 2 3
1 4 55 6
2 7 8 9
3 17 2 93
df3
a b c x y
0 1 2.0 3.0 2 3
1 4 5.0 6.0 55 6
2 7 8.0 9.0 8 9
3 17 NaN NaN 2 93
Parameters:
df: Union[pd.Series, pd.DataFrame]
forupdate: Union[pd.Series, pd.DataFrame]
update_existing_values:bool
(default=True)
add_new_columns=True
(default=True)
add_new_rows=True
(default=True)
Returns:
Union[pd.Series, pd.DataFrame]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file a_pandas_ex_df_updater-0.11.tar.gz
.
File metadata
- Download URL: a_pandas_ex_df_updater-0.11.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56abc46e355071f131e0cb9cc34b3036e33e2846889c17b25704777492e3e05f |
|
MD5 | 8623aabdedc7f47b90d8b9b7484e54dd |
|
BLAKE2b-256 | 890180e6b2c39f1cdbc83add1b01484d645d7f2cebc473614609c8a490f03305 |
File details
Details for the file a_pandas_ex_df_updater-0.11-py3-none-any.whl
.
File metadata
- Download URL: a_pandas_ex_df_updater-0.11-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c60000c553b7c7987702a016178264320bb39ad1e086ecb4200f535e7a1f65 |
|
MD5 | 683f60fca7c4ea76c845ffdada1cca63 |
|
BLAKE2b-256 | 24c3fe63918894d188b0e7ffee2471343202b80a6f115a36f6a9079bedca0dea |