这是与其他帖子类似的帖子,但是在我的情况下,日期列的格式似乎有所不同(我有一个包含数据和股票行情自动收录器的多重索引)
2014-05-01 09:31:00 + 00:00
我只想过滤此特定数据/时间,但这不起作用,并且返回并清空数据框:
#include <vector>
#include <iostream>
#include <algorithm>
struct B
{
static const int BIGGEST_TYPE_SIZE;
template <std::size_t DerSize>
B (std::integral_constant<std::size_t, DerSize>)
{ static_assert( DerSize <= BIGGEST_TYPE_SIZE, "!" ); }
};
template <typename Der>
struct C : public B
{
C() : B{std::integral_constant<std::size_t, sizeof(Der)>{}}
{ }
};
struct D1 : public C<D1>
{ int i; };
struct D2 : public C<D2>
{ std::vector<int> vec; };
struct D3 : public C<D3>
{ std::string s; };
struct D4 : public C<D4>
{ int a[42]; };
const int B::BIGGEST_TYPE_SIZE
= std::max({sizeof(D1), sizeof(D2), sizeof(D3)}); // <-- sizeof(D4) forgotten !!!
int main ()
{
D1 d1;
D2 d2;
D3 d3;
// D4 d4; compilation error
}
答案 0 :(得分:1)
from io import StringIO
import pandas as pd
df = pd.read_csv(StringIO(
"""timestamp,dummy1,dummy2
2014-05-01 09:31:00+00:00,1,3
2014-05-01 09:32:00+00:00,2,4
"""
), parse_dates=['timestamp'])
# use a multi index
df = df.set_index(['timestamp', 'dummy1'])
dummy2
timestamp dummy1
2014-05-01 09:31:00+00:00 1 3
2014-05-01 09:32:00+00:00 2 4
过滤2014-05-01 09:31
df.loc['2014-05-01 09:31']
dummy2
timestamp dummy1
2014-05-01 09:31:00+00:00 1 3