使用熊猫格式化datetime列

时间:2020-10-20 08:29:42

标签: python pandas

我需要删除熊猫日期时间列中点后的点和数字:

n=int(input("Enter the number of students:"))
i=1
with open("output_data.txt","w") as f:
    while i<=n:
        student=int(input("For students "))
        name=input("Enter name:")
        score=int(input("Enter the score:"))
        i+=1
        f.write("name: "+ name + " Score: " + str(score))
with open("output_data.txt") as f:
        print(f.read())

我编写了这段代码,但结果是相同的(点后的数字):

0   2020-01-05 21:58:15.030099
1   2020-01-09 09:15:01.286888

如何删除它?

1 个答案:

答案 0 :(得分:1)

您可以几秒钟内使用Series.dt.floor

#include <OpenSSL/obj_mac.h>
#include <OpenSSL/evp.h>
#include <OpenSSL/pem.h>
#include <OpenSSL/bio.h> 

bool SHA256WithRSA(const std::string RSAKey, const std::string Data)
{
    struct bio_st* pem_BIO = BIO_new(BIO_s_mem());
    if (BIO_write(pem_BIO, RSAKey.data(), RSAKey.size()) != RSAKey.size())
    {
        BIO_free_all(pem_BIO);
        return false;
    }
    struct evp_pkey_st* signing_key = PEM_read_bio_PrivateKey(pem_BIO, nullptr, nullptr, nullptr);
    if(signing_key == nullptr)
    {
        BIO_free_all(pem_BIO);
        EVP_PKEY_free(signing_key);
        return false;
    }
    
    std::string ResultBuffer(EVP_PKEY_size(signing_key), '\0');
    unsigned int len = 0;
    struct evp_md_ctx_st * MD_ctx = EVP_MD_CTX_new();
    if (!EVP_SignInit(MD_ctx, EVP_get_digestbyname(SN_sha256WithRSAEncryption)) ||
        !EVP_SignUpdate(MD_ctx, Data.data(), Data.size()) ||
        EVP_SignFinal(MD_ctx, (unsigned char*)ResultBuffer.data(), &len, signing_key) == 0)
    {
        BIO_free_all(pem_BIO);
        EVP_PKEY_free(signing_key);
        EVP_MD_CTX_free(MD_ctx);
        return false;
    }
    ResultBuffer.resize(len);
    
    /* Do something with the ResultBuffer */
    
    BIO_free_all(pem_BIO);
    EVP_PKEY_free(signing_key);
    EVP_MD_CTX_free(MD_ctx);
    return true;
}