i would like to concatenate the string value of one column’s entries with those from another dataframe’s column entries where the numbered index ids of the entries match, but the column length does not. ( df1 has 1000 entries, df2 has 100 entries)
this is what i have for code:
“””
####failed approach #1:
df1[“File-Name:”] = df1[“File-Name:”] + df2[“File-Name:”]
####failed approach #2
df1[“File-Name:”] = df1[“File-Name:”].str.cat(df2[“File-Name:”])
“””
i would like to understand why i am having issues with the syntax in these two faulted approaches:
both came up with only resolving the merged file names, all file names that needed no merge were replaced with Nan. i’m thinking there is some kind of datatype issue here but i would think they ought be strings. i would like to understand the failings of my two approaches and how they could be modified, if possible to achieve my end.
both approaches resulted in the same outcome. row 14 is correct, but the Nan entries are suppose to retain their original values:
> File-Name: date-time: Size:
> 0 NaN 2024-04-26 18:07 830172
> 1 NaN 2024-03-29 19:09 506588
> 2 NaN 2024-04-26 16:14 469096
> 3 NaN 2024-04-18 17:31 437680
> 4 NaN 2024-04-18 17:31 437676
> 5 NaN 2024-04-18 17:31 437672
> 6 NaN 2024-03-29 19:09 430596
> 7 NaN 2024-03-29 19:09 430592
> 8 NaN 2024-04-17 13:01 377076
> 9 NaN 2024-04-26 16:07 362192
> 10 NaN 2024-04-26 16:07 238260
> 11 NaN 2024-03-06 19:11 171496
> 12 NaN 2024-03-06 19:24 167192
> 13 NaN 2024-03-06 19:27 166940
> 14 ./.c9/dependencies/node18-linux-x64/7e2ea6e5edddeede43c966070975591a581c4ae0792a9b1a8af685de0311e77fec00f3ce2303de1affbe390e7b22b96402f66e9354a817ac84e6e0cd7eb74bd1 2024-03-06 19:27 166936
tooDeeStoned is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.