I’m trying to check whether a value exists in a dataframe or not and if so return “in dataframe”. In the past I have used:
findall(x → x==“value I want”, Dataframe)
Is there anyway to adapt this formula to search for the value across the dataframe?
When I try to search for a value I know is located somewhere in the dataframe I get the below error:
MethodError: no method matching keys(::DataFrames.DataFrame)
Closest candidates are:
keys(!Matched::Cmd) at process.jl:638
keys(!Matched::Core.SimpleVector) at essentials.jl:603
keys(!Matched::IndexLinear, !Matched::DataFrames.GroupedDataFrame) at
When I try to run this I get the below error:
MethodError: no method matching ∋(::Int64)
Closest candidates are:
∋(::Any, ::Any) at operators.jl:1069
Stacktrace:
[1] top-level scope at none:1
Thank you for your reply. I have been trying to adapt your function for what I am trying to do and apologise for not being specific enough in my initial post.
Some context to what I am trying to do:
I have 2 seperate dataframes Asset_Data and Project Data.
Asset_Data has 3 columns:
asset_id, country, cashflow
The Project Data dataframe has multiple columns (300 different columns)
Project name, type 1, type 2, …
I am trying to create a new column in my Asset_Data dataframe “Asset ID/Project” which identifies whether the asset_id is located in the Project Data dataframe or not.
Any idea how to do something like this?
What I have tried:
I have tried passing the values individually to check if it works - which it does. However, when I try to loop through the values from the Asset Data I’m finding issues with creating my new “Asset ID/Project” column.
Thank you this works. However, I noticed it is producing a column full of false. I think I am having issues find the value in the projects dataframe when the asset_id is not in the first column.
This produces the same column as previous (I.e. false).
I think the issue might be the functions itself. I don’t think the find_all function is actually finding the values when they not located in the first column of the Project Data frame.
Thank you for the detailed worked example - much appreciated. I have been able to replicate this in Julia and can see that the function does work (my apologies).
I have also been able to replicate using my worked example - thank you all, your time is very much appreciated