New fish, she’s swimming weird and won’t eat. Can someone tell me what illness this is?

I recently got a new fish and noticed she is behaving weird. She’s swimming down really fast and then floating back up while bobbing side to side and then repeating the process. When she’s not doing that, she’s sitting completely still at the bottom, trying to hide. I also noticed today that she wasn’t eating. I tried quarantining her in a small tank to get her to notice the food better, but she wouldn’t budge. I found her just now, wrapped around the filter, unable to move and she looked dead, the only way I could tell she was alive was that her little mouth was moving. I immediately turned off the filter and she swam away from it and started doing the weird bobbing side to side swimming. I even saw her swimming upside down yesterday too. It’s ironic because the reason I got her and a few other friends was to replace my fish, Koreth, who unfortunately passed last week, but Koreth had the EXACT same behaviors that my new girl is having, the only thing was that Koreth was able to eat a little more than the new girl. On Koreths last week, he was hiding and always on the bottom, when he was usually active. He was also swimming in the same crazy bobbing/floating way my new girl is. Another thing is that the other new fish I got with her are thriving, it’s only her behaving this way. So I’m already preparing to have her not live long, good thing I haven’t gotten TOO attached yet… but what illness is this? And can I cure it or prevent it, and if so how?