<p dir="auto">Hi there!</p>
<p dir="auto">I am using an anaconda 4.3.18 64 bits installation on windows 7. the version of python is 3.6.1 and numpy version is 1.12.1</p>
<p dir="auto">I imported an ascii file, and ran these commands:<br>
import numpy as np</p>
<h1 dir="auto">read the ascii file into attribute variable</h1>
<p dir="auto">sorted_items= np.sort(attribute, axis=0)<br>
sorted_ids= np.argsort(attribute,axis=0)</p>
<p dir="auto">Then, I exported sorted_items and sorted_ids to an ASCII file.</p>
<p dir="auto">Thereafter, I imported the same file in Octave version 4.2.0 64 bits and ran this command:<br>
[sorted_items,sorted_ids]= sort(attribute)</p>
<p dir="auto">Also, I exported the outputs to an ASCII file.</p>
<p dir="auto">When I compared these outputs, I noticed the following:</p>
<ul dir="auto">
<li>The sorted values in Python match those in Octave</li>
<li>The sorted index show issues.  The index reported by numpy are different to those reported by Octave in many places (see the excell spreadsheet, rows with blue background)</li>
<li>The sorted index show some good matches. A good index match is when the Octave index is one value higher than the one for Python (because Octave starts counting from 1, instead of 0 for Python)</li>
</ul>
<p dir="auto">I attached to this issue two files: the excell spreadsheet, and the text file containing the data used to report this issue.</p>
<p dir="auto">Many thanks,<br>
Ivan<br>
<a href="https://github.com/numpy/numpy/files/1145419/Data.zip">Data.zip</a></p>
<h3 dir="auto">Describe the issue:</h3>
<h3 dir="auto">Describe your issue.</h3>
<p dir="auto">From the attached CSV file, <a href="https://github.com/scipy/scipy/files/11653905/input_data.csv">input_data.csv</a>, I import the, say, <code class="notranslate">test_list</code>. Then, I create a <code class="notranslate">pd.Dataframe</code> to store my data in <code class="notranslate">test_df</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from scipy import fft
import numpy as np

test_df = pd.DataFrame(index=range(len(test_list)), columns=['test'])
test_df['test'] = test_list"><pre class="notranslate"><code class="notranslate">from scipy import fft
import numpy as np

test_df = pd.DataFrame(index=range(len(test_list)), columns=['test'])
test_df['test'] = test_list
</code></pre></div>
<p dir="auto">I want to calculate the FFT transform of the signal in <code class="notranslate">test_df['test']</code>. However, I get different results when I pass as input different types of arguments to the <code class="notranslate">scipy.fft.fft()</code>.</p>
<p dir="auto">Once I pass the signal as a nympy.array I get the plot <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="317838" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/1" data-hovercard-type="pull_request" data-hovercard-url="/numpy/numpy/pull/1/hovercard" href="https://github.com/numpy/numpy/pull/1">#1</a>.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/88409436/243393150-7cab8d6a-45e1-4e7f-a377-2d601b84c40b.png"><img src="https://user-images.githubusercontent.com/88409436/243393150-7cab8d6a-45e1-4e7f-a377-2d601b84c40b.png" alt="dummy" style="max-width: 100%;"></a></p>
<p dir="auto">Once I pass the signal as a pd.Dataframe I get the plot <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="365753" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/2" data-hovercard-type="pull_request" data-hovercard-url="/numpy/numpy/pull/2/hovercard" href="https://github.com/numpy/numpy/pull/2">#2</a>.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/88409436/243393235-41fb7740-5c23-4d59-b0f4-a7c5f20ac42c.png"><img src="https://user-images.githubusercontent.com/88409436/243393235-41fb7740-5c23-4d59-b0f4-a7c5f20ac42c.png" alt="dummy" style="max-width: 100%;"></a></p>
<p dir="auto">Both inputs, np.array and pd.DataFrame contain the same information.</p>
<p dir="auto">From the problem definition the plot#2 seems to have a better physical interpretation.<br>
However, it is not clear why I get different results.</p>
<p dir="auto">May be it is a bug?</p>
<p dir="auto">The code I use is below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from scipy import fft
import numpy as np

test_df = pd.DataFrame(index=range(len(test_list)), columns=['test'])
test_df['test'] = test_list


########## PLOT 1: from Numpy  ##############

to_np = test_df['test'].to_numpy()
print(to_np)

fft_output = fft.fft(to_np)
power = np.abs(fft_output)
freq = numpy.fft.fftfreq(len(to_np))

mask = freq &gt;= 0
freq = freq[mask]
power = power[mask]


plt.plot(freq, power)
plt.show()


########## PLOT 2: from pd.DataFrame  ##############

to_df = test_df['test'].to_frame()
print(to_df)

fft_output = numpy.fft.fft(to_df)
power = np.abs(fft_output)
freq = fft.fftfreq(len(to_df))


mask = freq &gt;= 0
freq = freq[mask]
power = power[mask]


plt.plot(freq, power)
plt.show()
"><pre class="notranslate"><code class="notranslate">from scipy import fft
import numpy as np

test_df = pd.DataFrame(index=range(len(test_list)), columns=['test'])
test_df['test'] = test_list


########## PLOT 1: from Numpy  ##############

to_np = test_df['test'].to_numpy()
print(to_np)

fft_output = fft.fft(to_np)
power = np.abs(fft_output)
freq = numpy.fft.fftfreq(len(to_np))

mask = freq &gt;= 0
freq = freq[mask]
power = power[mask]


plt.plot(freq, power)
plt.show()


########## PLOT 2: from pd.DataFrame  ##############

to_df = test_df['test'].to_frame()
print(to_df)

fft_output = numpy.fft.fft(to_df)
power = np.abs(fft_output)
freq = fft.fftfreq(len(to_df))


mask = freq &gt;= 0
freq = freq[mask]
power = power[mask]


plt.plot(freq, power)
plt.show()

</code></pre></div>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from scipy import fft
import numpy as np

test_df = pd.DataFrame(index=range(len(test_list)), columns=['test'])
test_df['test'] = test_list


########## PLOT 1: from Numpy  ##############

to_np = test_df['test'].to_numpy()
print(to_np)

fft_output = fft.fft(to_np)
power = np.abs(fft_output)
freq = numpy.fft.fftfreq(len(to_np))

mask = freq &gt;= 0
freq = freq[mask]
power = power[mask]


plt.plot(freq, power)
plt.show()


########## PLOT 2: from pd.DataFrame  ##############

to_df = test_df['test'].to_frame()
print(to_df)

fft_output = numpy.fft.fft(to_df)
power = np.abs(fft_output)
freq = fft.fftfreq(len(to_df))


mask = freq &gt;= 0
freq = freq[mask]
power = power[mask]


plt.plot(freq, power)
plt.show()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">scipy</span> <span class="pl-k">import</span> <span class="pl-s1">fft</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-s1">test_df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-en">range</span>(<span class="pl-en">len</span>(<span class="pl-s1">test_list</span>)), <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">'test'</span>])
<span class="pl-s1">test_df</span>[<span class="pl-s">'test'</span>] <span class="pl-c1">=</span> <span class="pl-s1">test_list</span>


<span class="pl-c">########## PLOT 1: from Numpy  ##############</span>

<span class="pl-s1">to_np</span> <span class="pl-c1">=</span> <span class="pl-s1">test_df</span>[<span class="pl-s">'test'</span>].<span class="pl-en">to_numpy</span>()
<span class="pl-en">print</span>(<span class="pl-s1">to_np</span>)

<span class="pl-s1">fft_output</span> <span class="pl-c1">=</span> <span class="pl-s1">fft</span>.<span class="pl-en">fft</span>(<span class="pl-s1">to_np</span>)
<span class="pl-s1">power</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">abs</span>(<span class="pl-s1">fft_output</span>)
<span class="pl-s1">freq</span> <span class="pl-c1">=</span> <span class="pl-s1">numpy</span>.<span class="pl-s1">fft</span>.<span class="pl-en">fftfreq</span>(<span class="pl-en">len</span>(<span class="pl-s1">to_np</span>))

<span class="pl-s1">mask</span> <span class="pl-c1">=</span> <span class="pl-s1">freq</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span>
<span class="pl-s1">freq</span> <span class="pl-c1">=</span> <span class="pl-s1">freq</span>[<span class="pl-s1">mask</span>]
<span class="pl-s1">power</span> <span class="pl-c1">=</span> <span class="pl-s1">power</span>[<span class="pl-s1">mask</span>]


<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">freq</span>, <span class="pl-s1">power</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()


<span class="pl-c">########## PLOT 2: from pd.DataFrame  ##############</span>

<span class="pl-s1">to_df</span> <span class="pl-c1">=</span> <span class="pl-s1">test_df</span>[<span class="pl-s">'test'</span>].<span class="pl-en">to_frame</span>()
<span class="pl-en">print</span>(<span class="pl-s1">to_df</span>)

<span class="pl-s1">fft_output</span> <span class="pl-c1">=</span> <span class="pl-s1">numpy</span>.<span class="pl-s1">fft</span>.<span class="pl-en">fft</span>(<span class="pl-s1">to_df</span>)
<span class="pl-s1">power</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">abs</span>(<span class="pl-s1">fft_output</span>)
<span class="pl-s1">freq</span> <span class="pl-c1">=</span> <span class="pl-s1">fft</span>.<span class="pl-en">fftfreq</span>(<span class="pl-en">len</span>(<span class="pl-s1">to_df</span>))


<span class="pl-s1">mask</span> <span class="pl-c1">=</span> <span class="pl-s1">freq</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">0</span>
<span class="pl-s1">freq</span> <span class="pl-c1">=</span> <span class="pl-s1">freq</span>[<span class="pl-s1">mask</span>]
<span class="pl-s1">power</span> <span class="pl-c1">=</span> <span class="pl-s1">power</span>[<span class="pl-s1">mask</span>]


<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">freq</span>, <span class="pl-s1">power</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<h3 dir="auto">Error message:</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Runtime information:</h3>
<p dir="auto">1.23.5<br>
3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:38:11)<br>
[Clang 14.0.6 ]</p>
<h3 dir="auto">Context for the issue:</h3>
<p dir="auto"><em>No response</em></p>