擅长:python、mysql、java
<p>我在你的问题中看到了多个子问题</p>
<ul>
<li>最后发生
看看这个方法:<a href="https://stackoverflow.com/questions/44420846/getting-days-since-last-occurence-in-pandas-dataframe">Getting days since last occurence in Pandas DataFrame?</a>
讨论了计算效率</李>
<li>首次出现:</li>
</ul>
<pre><code>df = df.merge(df.groupby("sender").agg(first_occurence_date=("Date","min"))["sender", "first_occurrence_date"], on="sender", how="left")
# Computationally likely inefficient, and doesn't solve multiple file-issue immediately.
</code></pre>
<ul>
<li>计算效率高的解决方案:
为了快速阅读,考虑使用^ {CD1}}作为一种有效的存储格式。此操作的标准会更改,因此始终保留<code>.csv</code>作为备份。
您可以像这样<code>df.to_feather("filename")</code>编写一个文件作为feather</li>
</ul>
<P>考虑用<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.factorize.html" rel="nofollow noreferrer">Pandas Docs: pd.Factorize()</a>中描述的{{CD4}}来对字符串进行分解。我在这上面没有看到基准,但比较^ {CD5>}要比^ {CD6>}快。<p>
<>最后,考虑建立一个小的SqLeTe3数据库,读取各个文件并存储它们。否则,获取第一个匹配项将是一件痛苦的事情,因为您必须不断覆盖旧值并多次执行计算代价高昂的操作</p>