Pandas数据框:如何实现没有标题的for循环

ecbunoof  于 2023-01-19  发布在  其他
关注(0)|答案(1)|浏览(235)

这是我的代码中非常基本的部分,我用它来排序日期,最后用其他列来匹配排序,然而,为了使这个工作,我需要它只说我的admission one,而不是在每个for循环中,有没有更好的方法来做这个,这里有大约1000个日期。
代码:

import pandas as pd
import os
import xlrd
import csv
import openpyxl
from openpyxl import load_workbook
from datetime import datetime

Need_Date = ['2022-12-30', '2023-1-9', '2023-1-23', '2023-2-13', '2023-2-27', '2023-3-16', '2023-4-14', '2023-4-14', '2023-5-12', '2023-5-4', '2023-6-2', '2023-6-2', '2023-6-30', '2024-2-16', '2024-3-15', '2022-10-28', '2022-11-15', '2022-8-5', '2022-12-30', '2022-8-26', '2022-8-26', '2022-8-26', '2023-1-30', '2022-8-19', '2022-9-20', '2022-10-20', '2022-11-22', '2022-12-19', '2022-12-6', '2023-1-20', '2023-1-11', '2023-2-22', '2023-2-8', '2023-3-22', '2023-3-8', '2023-4-20', '2023-4-10', '2023-5-22', '2023-5-10', '2023-6-22', '2023-4-27', '2023-6-6', '2023-7-20', '2023-3-8', '2023-5-31', '2023-5-31', '2023-5-31', '2023-5-31', '2023-7-11', '2023-8-22', '2024-1-5', '2024-2-12', '2024-2-8', '2024-3-15', '2022-12-21', '2022-12-15', '2023-1-11', '2023-2-8', '2023-2-8', '2023-3-31', '2023-1-10', '2023-1-10', '2023-1-11', '2023-1-13', '2023-1-16', '2023-2-7', '2023-2-7', '2023-2-7', '2023-2-7', '2023-2-7', '2023-2-7', '2023-2-7', '2023-3-7', '2023-3-7', '2023-4-28', '2023-1-13', '2023-2-7', '2023-2-7', '2023-2-8', '2023-2-8', '2023-2-9', '2023-2-9', '2023-2-10', '2023-2-10', '2023-2-10', '2023-2-13', '2023-2-13', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-3-7', '2023-4-4', '2023-4-4', '2023-5-26', '2022-8-12', '2022-11-23', '2022-9-7', '2022-9-7', '2022-12-29', '2022-10-5', '2022-10-5', '2022-10-5', '2022-10-5', '2023-1-27', '2022-11-9', '2022-11-9', '2022-11-9', '2022-11-9', '2022-11-9', '2022-11-9', '2022-11-9', '2023-3-3', '2022-12-8', '2022-12-8', '2022-12-8', '2022-12-8', '2022-12-8', '2022-12-8', '2022-12-8', '2022-12-8', '2022-12-8', '2023-3-30', '2023-1-10', '2023-1-10', '2023-1-10', '2023-1-10', '2023-1-10', '2023-1-10', '2023-1-10', '2023-1-10', '2023-1-10', '2023-4-28', '2022-11-15', '2023-2-13', '2023-2-13', '2023-2-13', '2023-2-13', '2023-2-13', '2023-2-13', '2023-2-13', '2023-2-13', '2023-2-13', '2023-2-13', '2023-6-2', '2022-12-13', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-3-9', '2023-6-28', '2023-1-13', '2023-1-13', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-4-6', '2023-7-28', '2023-2-16', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-5-11', '2023-8-31', '2023-3-16', '2023-3-16', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-6-9', '2023-9-29', '2023-4-13', '2023-4-13', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-7-10', '2023-10-26', '2023-2-20', '2023-2-20', '2023-5-10', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-8-4', '2023-11-24', '2023-3-22', '2023-6-12', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-9-6', '2023-12-28', '2023-4-20', '2023-7-12', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2023-10-4', '2024-1-26', '2023-5-25', '2023-8-16', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2023-11-8', '2024-3-1', '2023-6-23', '2023-9-14', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2023-12-8', '2024-3-29', '2023-8-1', '2023-10-19', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-1-17', '2024-5-3', '2023-8-29', '2023-11-17', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-2-14', '2024-5-31', '2023-9-27', '2023-12-18', '2024-1-3', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-3-13', '2024-6-28', '2023-10-31', '2024-1-24', '2024-2-6', '2024-2-6', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-4-16', '2024-8-1', '2023-12-1', '2024-2-22', '2024-3-6', '2024-3-6', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-5-15', '2024-8-30', '2024-1-9', '2024-3-27', '2024-4-9', '2024-4-9', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-6-18', '2024-10-3', '2024-2-7', '2024-4-25', '2024-5-8', '2024-5-8', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-7-17', '2024-11-1', '2024-2-28', '2024-5-16', '2024-5-29', '2024-5-29', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-8-7', '2024-11-22', '2024-4-10', '2024-6-27', '2024-7-10', '2024-7-10', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2024-9-18', '2025-1-3', '2024-4-23', '2024-5-8', '2024-7-25', '2024-8-7', '2024-8-7', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2024-10-16', '2025-1-31', '2024-5-21', '2024-6-5', '2024-8-22', '2024-9-4', '2024-9-4', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2024-11-13', '2025-2-28', '2024-6-21', '2024-7-8', '2024-9-24', '2024-10-7', '2024-10-7', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2024-12-16', '2025-4-2', '2022-8-8', '2022-8-8', '2022-8-8', '2022-8-8', '2022-12-28', '2022-11-2', '2022-11-2', '2022-11-2', '2022-11-2', '2022-11-2', '2022-11-2', '2022-11-2', '2023-3-30', '2022-8-12', '2022-11-30', '2022-9-6', '2022-9-6', '2022-9-6', '2022-9-6', '2022-12-30', '2022-10-4', '2022-10-4', '2022-10-4', '2022-10-4', '2022-10-4', '2022-10-4', '2023-1-30', '2022-11-1', '2022-11-1', '2022-11-1', '2022-11-1', '2022-11-1', '2022-11-1', '2023-2-27', '2022-12-6', '2022-12-6', '2022-12-6', '2022-12-6', '2022-12-6', '2022-12-6', '2022-12-6', '2023-3-30', '2022-12-12', '2023-1-6', '2023-1-6', '2023-1-6', '2023-1-6', '2023-1-6', '2023-1-6', '2023-1-6', '2023-1-6', '2023-1-6', '2023-1-6', '2023-4-28', '2023-1-13', '2023-1-13', '2023-2-6', '2023-2-6', '2023-2-6', '2023-2-6', '2023-2-6', '2023-2-6', '2023-2-6', '2023-2-6', '2023-5-30', "['Future']", '2022-12-12', '2022-12-13', '2022-12-14', '2022-12-15', '2022-12-16', '2022-12-14', '2022-12-14', '2022-12-14', '2022-12-14', '2023-1-30', '2023-1-24', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-3-30', '2023-2-3', '2023-2-6', '2023-2-21', '2023-2-21', '2023-2-24', '2023-3-16', '2023-3-16', '2023-3-16', '2023-3-16', '2023-3-16', '2023-3-16', '2023-3-16', '2023-3-16', '2023-4-28', '2022-4-14', '2022-8-18', '2022-11-3', '2022-11-3', '2022-11-4', '2022-12-7', '2022-12-7', '2022-12-8', '2022-12-9', '2023-1-27', '2023-1-27', '2023-3-10', '2023-3-10', '2023-4-20', '2023-4-21', '2023-6-1', '2023-6-2', '2023-6-5', '2022-4-13', '2022-7-12', '2022-7-28', '2022-10-14', '2022-10-14', '2022-10-14', '2022-10-14', '2023-1-30', '2022-5-12', '2022-8-9', '2022-8-25', '2022-11-11', '2022-11-11', '2022-11-11', '2022-11-11', '2023-2-27', '2022-6-13', '2022-9-7', '2022-9-23', '2022-12-13', '2022-12-13', '2022-12-13', '2022-12-13', '2022-12-13', '2023-3-27', '2022-7-11', '2022-10-4', '2022-10-20', '2023-1-12', '2023-1-12', '2023-1-12', '2023-1-12', '2023-1-12', '2023-1-12', '2023-4-24', '2022-8-15', '2022-11-8', '2022-11-28', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-2-16', '2023-5-30', '2022-12-29', '2022-3-25', '2022-7-22', '2021-8-4', '2022-2-4', '2022-4-4', '2022-5-3', '2022-5-3', '2022-5-3', '2022-5-3', '2022-5-3', '2022-5-3', '2022-5-3', '2022-5-3', '2022-9-15', '2022-9-15', '2022-9-15', '2023-2-2', '2022-9-28', '2022-9-28', '2022-12-9', '2022-11-3', '2022-11-3', '2023-1-19', '2023-1-19', '2022-8-12', '2023-1-10', '2023-1-17', '2022-8-19', '2022-8-19', '2023-1-23', '2023-1-30', '2022-8-12', '2022-8-12', '2022-9-19', '2022-9-19', '2022-9-19', '2022-9-19', '2022-9-19', '2022-9-19', '2023-2-20', '2023-2-27', '2022-8-8', '2022-8-8', '2022-9-1', '2022-9-1', '2022-9-1', '2022-10-7', '2022-10-7', '2022-10-7', '2022-10-7', '2022-10-7', '2022-10-7', '2023-3-10', '2023-3-17', '2022-8-22', '2022-8-22', '2022-9-16', '2022-9-16', '2022-9-16', '2022-9-16', '2022-10-21', '2022-10-21', '2022-10-21', '2022-10-21', '2022-10-21', '2022-10-21', '2023-3-24', '2023-3-31', '2022-8-29', '2022-8-29', '2022-9-23', '2022-9-23', '2022-9-23', '2022-10-28', '2022-10-28', '2022-10-28', '2022-10-28', '2022-10-28', '2022-10-28', '2022-10-28', '2023-3-31', '2023-4-10', '2022-8-29', '2022-9-20', '2022-9-20', '2022-10-14', '2022-10-14', '2022-10-14', '2022-11-18', '2022-11-18', '2022-11-18', '2022-11-18', '2022-11-18', '2022-11-18', '2022-11-18', '2023-4-24', '2023-5-1', '2022-10-17', '2022-10-17', '2022-11-10', '2022-11-10', '2022-11-10', '2022-11-10', '2022-12-19', '2022-12-19', '2022-12-19', '2022-12-19', '2022-12-19', '2022-12-19', '2022-12-19', '2023-5-19', '2023-5-26', '2022-10-12', '2022-11-11', '2022-11-11', '2022-12-9', '2022-12-9', '2022-12-9', '2023-1-18', '2023-1-18', '2023-1-18', '2023-1-18', '2023-1-18', '2023-1-18', '2023-1-18', '2023-6-16', '2023-6-23', '2022-12-7', '2022-12-8', '2023-1-11', '2023-1-11', '2023-1-11', '2023-2-6', '2023-2-6', '2023-2-6', '2023-3-13', '2023-3-13', '2023-3-13', '2023-3-13', '2023-3-13', '2023-3-13', '2023-3-13', '2023-8-11', '2023-8-18', '2023-1-13', '2023-1-16', '2023-2-14', '2023-2-14', '2023-2-14', '2023-3-10', '2023-3-10', '2023-3-10', '2023-4-17', '2023-4-17', '2023-4-17', '2023-4-17', '2023-4-17', '2023-4-17', '2023-4-17', '2023-9-15', '2023-9-22', '2023-1-20', '2023-1-23', '2023-2-21', '2023-2-21', '2023-3-17', '2023-3-17', '2023-3-17', '2023-4-24', '2023-4-24', '2023-4-24', '2023-4-24', '2023-4-24', '2023-4-24', '2023-4-24', '2023-9-22', '2023-9-29', '2023-2-17', '2023-2-20', '2023-3-21', '2023-3-21', '2023-4-17', '2023-4-17', '2023-4-17', '2023-5-22', '2023-5-22', '2023-5-22', '2023-5-22', '2023-5-22', '2023-5-22', '2023-5-22', '2023-10-20', '2023-10-27', '2023-1-30', '2023-1-31', '2023-3-15', '2023-3-16', '2023-4-17', '2023-4-17', '2023-4-17', '2023-5-11', '2023-5-11', '2023-5-11', '2023-6-16', '2023-6-16', '2023-6-16', '2023-6-16', '2023-6-16', '2023-6-16', '2023-6-16', '2023-11-16', '2023-11-24', '2023-3-24', '2023-3-27', '2023-5-10', '2023-5-11', '2023-6-12', '2023-6-12', '2023-7-10', '2023-7-10', '2023-7-10', '2023-8-14', '2023-8-14', '2023-8-14', '2023-8-14', '2023-8-14', '2023-8-14', '2023-8-14', '2024-1-16', '2024-1-23', '2022-8-18', '2022-11-30', '2022-9-16', '2022-9-16', '2022-9-16', '2022-9-16', '2022-12-30', '2023-3-15', '2023-3-15', '2023-3-15', '2023-3-15', '2023-3-15', '2023-3-15', '2023-3-15', '2023-3-15', '2023-3-15', '2023-6-26', '2023-1-25', '2023-1-26', '2023-4-13', '2023-4-13', '2023-4-13', '2023-4-13', '2023-4-13', '2023-4-13', '2023-4-13', '2023-4-13', '2023-4-13', '2023-7-26']
WO = [['13772630'], ['13800871'], ['13800872'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13733075'], ['13730947'], ['13608645A'], ['13765540'], ['13540239A'], ['13540239'], ['13747650'], ['13765550'], ['13772761'], ['13772762'], ['13772763'], ['13733589'], ['13772764'], ['13730079'], [None], ['13784131'], [None], ['13798652'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13683991'], ['13776721'], [None], [None], [None], [None], [None], [None], [None], [None], ['13777472'], ['13619294A'], [None], ['13799098'], ['13793944'], [None], [None], [None], [None], [None], ['13619294A'], ['13771271'], ['13736012'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13673732'], [None], ['13797863'], ['13801760'], ['13761276'], ['13735642'], [None], ['13619294'], ['13771908'], ['2207290J02  0001'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13765214B'], ['13796545'], ['13765214A'], ['13735682'], ['13796556'], ['13735682'], ['13731122'], ['13721667'], ['13733084'], [None], ['13731122'], ['13721667'], ['13733084C'], ['13761949'], ['13761803'], ['13761932'], ['13757496'], [None], ['13761949'], ['13761803'], ['13761932'], ['13757496'], ['13765339'], ['13762012'], ['13784790'], ['13765214'], ['13797343'], [None], ['13761949'], ['13761803'], ['13757496'], ['13765339'], ['13762012'], ['13784790'], ['13765214'], ['13797343'], ['13777870'], [None], ['13793082'], ['13761949'], ['13765339'], ['13797343'], ['13777870'], ['13783033'], ['13757085'], ['13733084A'], ['13799800'], ['13796986'], [None], [None], ['13793082'], ['13765339'], ['13797343'], ['13783033'], ['13757085'], ['13799800'], ['13796986'], ['13793101'], ['13796980'], [None], [None], [None], [None], ['13793082'], ['221108RS99  0001'], ['13765339'], ['13797343'], ['13799800'], ['13796986'], ['13793101'], ['13796980'], ['13796988'], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['221108RS99  0001'], ['13799800'], ['13796986'], ['13793101'], ['13796980'], ['13796988'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13793082'], ['221108RS99  0001'], ['13799800'], ['13796980'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['221108RS99  0001'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13521096A'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13790919'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13750217'], ['13716672'], ['13730670'], ['13730916'], ['13753552'], ['13701192A'], ['13764771'], ['13716672'], ['13730916'], ['13725857'], ['13791296'], [None], [None], ['13674695'], ['13796616'], ['13674695'], ['13680463A'], ['13680463'], ['13675108A'], [None], ['13675108A'], ['13674695A'], ['13674698B'], ['13703990'], ['13680462'], ['13675108'], [None], ['13703990'], ['13675108'], ['13725164'], ['13674698'], ['13727419'], ['13669270A'], [None], ['13725164'], ['13727419'], ['13717319'], ['13744451'], ['13717321'], ['13704003'], ['13704003B'], [None], ['13691871'], ['13717319'], ['13704003B'], ['13674695B'], ['13703991A'], ['13703991B'], ['13703991C'], ['13703991'], ['13717321A'], ['13726754'], [None], [None], ['13771004'], ['13691872A'], ['13717319'], ['13717321A'], ['13726754'], ['13725164A'], ['13727420'], ['13717321B'], ['13704003A'], [None], [None], [None], ['13606238'], ['13622176'], ['13628628'], ['13628629'], ['13628630'], ['13737544'], ['13728601'], ['13802197'], ['13798453'], ['13628631'], ['13802199'], ['13786602'], ['13737545'], ['13747646'], ['13784787'], [None], [None], [None], [None], ['13628632'], ['13782077'], ['13726137'], [None], [None], ['13729113'], ['13786595'], [None], [None], [None], [None], [None], [None], [None], ['13628633'], ['13746165'], ['13746165'], ['13746165'], ['13752527'], ['13752527'], ['13752527'], ['13761678'], ['13761678'], ['13761678'], ['13761678'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13713745'], ['13718045'], ['13688421'], [None], [None], [None], [None], [None], ['13718042'], ['13771955'], ['13713747'], [None], [None], [None], [None], [None], ['13720274'], ['13764732'], ['13795955'], ['13706927'], [None], [None], [None], [None], [None], ['13771954'], ['13701750'], ['13795958'], ['13771307'], ['13795967'], [None], [None], [None], [None], [None], ['13771307'], ['13793310'], ['13795965'], ['13795960'], ['13795968'], [None], [None], [None], [None], [None], ['13631323'], ['13617943'], [None], ['13802645'], ['13788435'], ['13782003'], ['13729725'], ['13766117'], ['13717164'], ['13788250'], ['13777984'], ['13788559'], [None], [None], ['13749507'], ['13749508'], ['13617947'], [None], ['13772555'], ['13750643'], ['13797898'], ['13777210'], ['13767114'], ['13743747'], [None], ['13742806A'], ['13794870'], [None], ['13790118A'], ['13742806A'], [None], [None], ['13731017'], ['13743758'], ['13790118'], ['13541633A'], ['13733450'], ['13733451'], ['13742806'], [None], [None], [None], ['13624358A'], ['13624356A'], ['13635634A'], ['13731017'], [None], ['13790118'], ['13733450'], ['13733451'], ['13676894A'], ['13742806'], [None], [None], [None], ['13624358A'], ['13624356A'], ['13635634A'], ['13776118'], ['13731017'], [None], ['13790118'], ['13733450'], ['13733451'], ['13676894C'], ['13742806'], [None], [None], [None], ['13624358A'], ['13624356A'], ['13776118'], ['13731017'], [None], ['13667144A'], ['13790118'], ['13733450'], ['13733451'], ['13742806'], ['13731019A'], [None], [None], [None], ['13797174'], ['13624358A'], ['13624356A'], ['13776118'], ['13731018'], [None], ['13790116'], ['13790118'], ['13733450'], ['13733451'], ['13731019A'], [None], [None], [None], [None], ['13624358A'], ['13624356A'], ['13776118'], ['13738119'], ['13731018'], [None], ['13790116'], ['13797298'], ['13731019A'], [None], [None], [None], [None], [None], [None], [None], ['13624358A'], ['13624356A'], ['13738119'], [None], [None], ['13790116'], ['13797298'], ['13731019A'], [None], [None], [None], [None], [None], [None], [None], ['13797174'], ['13624358A'], ['13624356A'], ['13624356E'], [None], [None], [None], ['13790116'], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13797176'], ['13624358A'], ['13624358D'], ['13624356E'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13624358D'], ['13624356E'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13624358D'], ['13624356E'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13624358D'], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], [None], ['13688928'], [None], ['13718038'], ['13688413'], ['13663616'], ['13721480'], [None], ['13771307'], ['13718039'], ['13795963'], ['13795964'], ['13797992'], ['13795973'], [None], [None], [None], [None], ['13740592'], [None], ['13771307'], ['13797991'], ['13797993'], ['13795966'], [None], [None], [None], [None], [None], [None]]
Rows_total = len(Need_Date)

for B in range(0, Rows_total):
    data = pd.DataFrame({'Needed date': [Need_Date[B]] })
    B = B+1     
    print(data)

输出:

Needed date
0   2023-4-13
  Needed date
0   2023-4-13
  Needed date
0   2023-4-13
  Needed date
0   2023-4-13
  Needed date
0   2023-7-26

预期产出

Needed date
0   2023-4-13
1   2023-4-13
2   2023-4-13
3   2023-4-13
4   2023-7-26
.....(in chronological date order from all sets of data).....

我使用的主要资源位于这里:https://www.geeksforgeeks.org/how-to-sort-a-pandas-dataframe-by-date/
我在网上看到的每个使用这个工具的例子,我都看到人们手动输入每一行,但每次都想单独存储一个数组。请让我知道这是否有意义,第一次发布。

rkue9o1l

rkue9o1l1#

我认为你不需要for循环。要将Need_Date转换为 Dataframe :

>>> data = pd.DataFrame({'Needed date': Need_Date})
>>> data
     Needed date
0     2022-12-30
1       2023-1-9
2      2023-1-23
3      2023-2-13
4      2023-2-27

要进行排序,我建议先转换为datetime,然后使用sort_values()方法

data['Needed date'] = pd.to_datetime(data['Needed date'])
data = data.sort_values('Needed date')

但是要注意,转换为datetime对示例数据不起作用,因为有一个值['Future']不能转换为datetime,我建议在排序之前将其从列表中删除。

相关问题