Using DeleteCases with a defined function with two arguments as a patternUsing DeleteCases with multiple AstronomicalData propertiesRemoving some data and replacing them with new onesAdvanced SQL-type select statements (filtering) on DatasetsFiltering outliersHow to remove outliers from dataPattern-matching Function with conditions on arbitrary number of argumentsHow to delete matrix elements where the conditions apply to more than one dimensional elementChange the point size in ListPlotHow do I remove particular $x$ and $y$ values from a list of data points?Cleaning away data points which are enveloped within a function
SFDX Can query Package Installation Status, can we?
How can I get a job without pushing my family's income into a higher tax bracket?
Short story with physics professor who "brings back the dead" (Asimov or Bradbury?)
How could a planet have most of its water in the atmosphere?
Does a wine bottle stopper require tevillah?
Why do we use caret (^) as the symbol for ctrl/control?
For a benzene shown in a skeletal structure, what does a substituent to the center of the ring mean?
Moving the subject of the sentence into a dangling participle
Why is B♯ higher than C♭ in 31-ET?
Besides the up and down quark, what other quarks are present in daily matter around us?
Answer "Justification for travel support" in conference registration form
Why was the battle set up *outside* Winterfell?
Roll Dice to get a random number between 1 and 150
How to give very negative feedback gracefully?
Python password manager
How can I close a gap between my fence and my neighbor's that's on his side of the property line?
What does this colon mean? It is not labeling, it is not ternary operator
Do I have to make someone coauthor if he/she solves a problem in StackExchange, asked by myself, which is later used in my paper?
Is induction neccessary for proving that every injective mapping of a finite set into itself is a mapping onto itself?
Can't remove one character of space in my environment
Airbnb - host wants to reduce rooms, can we get refund?
Catholic vs Protestant Support for Nazism in Germany
Would a 1/1 token with persist dying trigger on death effects a second time?
My ID is expired, can I fly to the Bahamas with my passport?
Using DeleteCases with a defined function with two arguments as a pattern
Using DeleteCases with multiple AstronomicalData propertiesRemoving some data and replacing them with new onesAdvanced SQL-type select statements (filtering) on DatasetsFiltering outliersHow to remove outliers from dataPattern-matching Function with conditions on arbitrary number of argumentsHow to delete matrix elements where the conditions apply to more than one dimensional elementChange the point size in ListPlotHow do I remove particular $x$ and $y$ values from a list of data points?Cleaning away data points which are enveloped within a function
$begingroup$
I am trying to manipulate some large datasets in Mathematica. I have plotted the data, and I would like to be able to easily remove points from the dataset, and it's fairly easy to identify the x-values of the points I need to remove. Let's say I need to remove the data point at an x-value of 1.1. To do this, I could do something like this:
BadData[entry_] := MatchQ[entry, 1.1, _?NumberQ]
goodData = DeleteCases[data, _?BadData]
However, I have 6 other data sets, all of which I have to remove different outliers (not at 1.1). I'd like to define a function such as
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
because then for bad
I can just put whatever the x-value is of the point I need to remove. I tested the function out by figuring out that the data point with 1.1 as the x-value is the 7th in data
, and running
BadData[data[[7]], 1.1]
returns True
. So I know the function works the way I want it to, even though I know this might not be the "prettiest" way to do this.
What I can't figure out is how to use this version of baddata as a pattern in DeleteCases because I don't know how to specify the second variable, which would be 1.1 for this set. Is this possible with the setup I have currently?
list-manipulation pattern-matching filtering dataset argument-patterns
New contributor
$endgroup$
add a comment |
$begingroup$
I am trying to manipulate some large datasets in Mathematica. I have plotted the data, and I would like to be able to easily remove points from the dataset, and it's fairly easy to identify the x-values of the points I need to remove. Let's say I need to remove the data point at an x-value of 1.1. To do this, I could do something like this:
BadData[entry_] := MatchQ[entry, 1.1, _?NumberQ]
goodData = DeleteCases[data, _?BadData]
However, I have 6 other data sets, all of which I have to remove different outliers (not at 1.1). I'd like to define a function such as
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
because then for bad
I can just put whatever the x-value is of the point I need to remove. I tested the function out by figuring out that the data point with 1.1 as the x-value is the 7th in data
, and running
BadData[data[[7]], 1.1]
returns True
. So I know the function works the way I want it to, even though I know this might not be the "prettiest" way to do this.
What I can't figure out is how to use this version of baddata as a pattern in DeleteCases because I don't know how to specify the second variable, which would be 1.1 for this set. Is this possible with the setup I have currently?
list-manipulation pattern-matching filtering dataset argument-patterns
New contributor
$endgroup$
1
$begingroup$
Try this:DeleteCases[data, _?(BadData[#, 1.1] &)]
$endgroup$
– Anjan Kumar
1 hour ago
add a comment |
$begingroup$
I am trying to manipulate some large datasets in Mathematica. I have plotted the data, and I would like to be able to easily remove points from the dataset, and it's fairly easy to identify the x-values of the points I need to remove. Let's say I need to remove the data point at an x-value of 1.1. To do this, I could do something like this:
BadData[entry_] := MatchQ[entry, 1.1, _?NumberQ]
goodData = DeleteCases[data, _?BadData]
However, I have 6 other data sets, all of which I have to remove different outliers (not at 1.1). I'd like to define a function such as
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
because then for bad
I can just put whatever the x-value is of the point I need to remove. I tested the function out by figuring out that the data point with 1.1 as the x-value is the 7th in data
, and running
BadData[data[[7]], 1.1]
returns True
. So I know the function works the way I want it to, even though I know this might not be the "prettiest" way to do this.
What I can't figure out is how to use this version of baddata as a pattern in DeleteCases because I don't know how to specify the second variable, which would be 1.1 for this set. Is this possible with the setup I have currently?
list-manipulation pattern-matching filtering dataset argument-patterns
New contributor
$endgroup$
I am trying to manipulate some large datasets in Mathematica. I have plotted the data, and I would like to be able to easily remove points from the dataset, and it's fairly easy to identify the x-values of the points I need to remove. Let's say I need to remove the data point at an x-value of 1.1. To do this, I could do something like this:
BadData[entry_] := MatchQ[entry, 1.1, _?NumberQ]
goodData = DeleteCases[data, _?BadData]
However, I have 6 other data sets, all of which I have to remove different outliers (not at 1.1). I'd like to define a function such as
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
because then for bad
I can just put whatever the x-value is of the point I need to remove. I tested the function out by figuring out that the data point with 1.1 as the x-value is the 7th in data
, and running
BadData[data[[7]], 1.1]
returns True
. So I know the function works the way I want it to, even though I know this might not be the "prettiest" way to do this.
What I can't figure out is how to use this version of baddata as a pattern in DeleteCases because I don't know how to specify the second variable, which would be 1.1 for this set. Is this possible with the setup I have currently?
list-manipulation pattern-matching filtering dataset argument-patterns
list-manipulation pattern-matching filtering dataset argument-patterns
New contributor
New contributor
New contributor
asked 1 hour ago
nwellsnwells
82
82
New contributor
New contributor
1
$begingroup$
Try this:DeleteCases[data, _?(BadData[#, 1.1] &)]
$endgroup$
– Anjan Kumar
1 hour ago
add a comment |
1
$begingroup$
Try this:DeleteCases[data, _?(BadData[#, 1.1] &)]
$endgroup$
– Anjan Kumar
1 hour ago
1
1
$begingroup$
Try this:
DeleteCases[data, _?(BadData[#, 1.1] &)]
$endgroup$
– Anjan Kumar
1 hour ago
$begingroup$
Try this:
DeleteCases[data, _?(BadData[#, 1.1] &)]
$endgroup$
– Anjan Kumar
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
You can use an implicit function more explicitly, as
data = 1, 5, 1.1, 6, 2, 7;
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
DeleteCases[data, _?(BadData[#, 1.1] &)]
1, 5, 2, 7
$endgroup$
add a comment |
$begingroup$
You can also define BadData
as a pure function:
BadData[bad_] := First[#] == bad&
Then:
DeleteCases[data, _?(BadData[1.1])]
1, 5, 2, 7
Another possibility is:
BadData[bad_] := EqualTo[bad] @* First
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
nwells is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197423%2fusing-deletecases-with-a-defined-function-with-two-arguments-as-a-pattern%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can use an implicit function more explicitly, as
data = 1, 5, 1.1, 6, 2, 7;
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
DeleteCases[data, _?(BadData[#, 1.1] &)]
1, 5, 2, 7
$endgroup$
add a comment |
$begingroup$
You can use an implicit function more explicitly, as
data = 1, 5, 1.1, 6, 2, 7;
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
DeleteCases[data, _?(BadData[#, 1.1] &)]
1, 5, 2, 7
$endgroup$
add a comment |
$begingroup$
You can use an implicit function more explicitly, as
data = 1, 5, 1.1, 6, 2, 7;
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
DeleteCases[data, _?(BadData[#, 1.1] &)]
1, 5, 2, 7
$endgroup$
You can use an implicit function more explicitly, as
data = 1, 5, 1.1, 6, 2, 7;
BadData[entry_, bad_] := MatchQ[entry, bad, _?NumberQ]
DeleteCases[data, _?(BadData[#, 1.1] &)]
1, 5, 2, 7
answered 1 hour ago
KagaratschKagaratsch
4,94731350
4,94731350
add a comment |
add a comment |
$begingroup$
You can also define BadData
as a pure function:
BadData[bad_] := First[#] == bad&
Then:
DeleteCases[data, _?(BadData[1.1])]
1, 5, 2, 7
Another possibility is:
BadData[bad_] := EqualTo[bad] @* First
$endgroup$
add a comment |
$begingroup$
You can also define BadData
as a pure function:
BadData[bad_] := First[#] == bad&
Then:
DeleteCases[data, _?(BadData[1.1])]
1, 5, 2, 7
Another possibility is:
BadData[bad_] := EqualTo[bad] @* First
$endgroup$
add a comment |
$begingroup$
You can also define BadData
as a pure function:
BadData[bad_] := First[#] == bad&
Then:
DeleteCases[data, _?(BadData[1.1])]
1, 5, 2, 7
Another possibility is:
BadData[bad_] := EqualTo[bad] @* First
$endgroup$
You can also define BadData
as a pure function:
BadData[bad_] := First[#] == bad&
Then:
DeleteCases[data, _?(BadData[1.1])]
1, 5, 2, 7
Another possibility is:
BadData[bad_] := EqualTo[bad] @* First
answered 1 hour ago
Carl WollCarl Woll
76.6k3100201
76.6k3100201
add a comment |
add a comment |
nwells is a new contributor. Be nice, and check out our Code of Conduct.
nwells is a new contributor. Be nice, and check out our Code of Conduct.
nwells is a new contributor. Be nice, and check out our Code of Conduct.
nwells is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197423%2fusing-deletecases-with-a-defined-function-with-two-arguments-as-a-pattern%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
Try this:
DeleteCases[data, _?(BadData[#, 1.1] &)]
$endgroup$
– Anjan Kumar
1 hour ago