如何解决pd.date_range ,值的长度与索引的长度不匹配
我有一个数据框组成如下,包含1971年到2017年的日降水数据:
start_date_entry = input("Input the month and the year to start your analysis (i.e. YYYY-MM-DD): ")
year,month,day = map(int,start_date_entry.split('-'))
start_date_form = datetime(year,day,7,0)
end_date_entry = input("Input the last month and year to end your analysis (i.e. YYYY-MM-DD): ")
year,end_date_entry.split('-'))
end_date_form = datetime(year,0)
我想询问用户他对过滤可用数据感兴趣的时间范围,因此:
type(start_date_form)
Out[31]: datetime.datetime
print(start_date_form)
2010-01-01 07:00:00
start_date_form 和 end_date_form 都具有以下格式:
df['date']=pd.date_range(start=(start_date_form),end=(end_date_form),freq='D')
现在,我想用新日期过滤我的数据框:
Length of values (1827) does not match length of index (17167)
我收到以下错误:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/myContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/button3"
android:layout_width="400dp"
android:layout_height="400dp"
android:layout_centerInParent="true"
app:srcCompat="@drawable/circle"
app:tint="#E60505" />
<ImageView
android:id="@+id/button2"
android:layout_width="400dp"
android:layout_height="400dp"
android:layout_centerInParent="true"
app:srcCompat="@drawable/circle"
app:tint="#FFB700" />
<ImageView
android:id="@+id/button1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentRight="false"
android:layout_centerInParent="true"
app:srcCompat="@drawable/circle" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
我是 Python 和编程的新手,我很感激这方面的帮助。谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。