Python Seaborn时间轴:显示日期而不是纳秒
我有一个带有日期列的熊猫数据框(Python Seaborn时间轴:显示日期而不是纳秒,python,date,matplotlib,seaborn,Python,Date,Matplotlib,Seaborn,我有一个带有日期列的熊猫数据框(RankingDate) 此日期字段最初是从csv加载的字符串,格式为“2006-11-03” 运行df[“RankingDate”]=pd.to_datetime(df[“RankingDate”])后,数据类型变为,请参见。我不会太依赖tsplot,因为它可能会在将来的某个seaborn版本中被删除或发生重大更改-我想原因是它造成了很多混乱。是否有任何理由使用tsplot?为什么不使用标准线图?也许能帮上忙?看。我不会太依赖于tsplot,因为它可能会在未来的
RankingDate
)
此日期字段最初是从csv加载的字符串,格式为“2006-11-03”
运行
df[“RankingDate”]=pd.to_datetime(df[“RankingDate”])
后,数据类型变为,请参见。我不会太依赖tsplot
,因为它可能会在将来的某个seaborn版本中被删除或发生重大更改-我想原因是它造成了很多混乱。是否有任何理由使用tsplot
?为什么不使用标准线图?也许能帮上忙?看。我不会太依赖于tsplot
,因为它可能会在未来的seaborn版本中被删除或有相当大的更改-我想原因是它引起了很多混乱。是否有任何理由使用tsplot
?为什么不使用标准线图?也许能帮上忙?
f, ax = plt.subplots(figsize=(16, 8))
sns.tsplot(data, time='RankingDate', unit='Dummy', condition='Player', value='Points', ax=ax)
import numpy as np
import pandas as pd
import seaborn as sns
RankingDate = ['2015-03-02','2015-03-03','2015-03-04','2015-03-05','2015-03-06']
Player = ['Player1','Player2','Player2','Player1','Player1']
Points = np.random.randn(5)
df = pd.DataFrame({'RankingDate': RankingDate , 'Player': Player, 'Points': Points})
df["RankingDate"]=pd.to_datetime(df["RankingDate"])
df["Dummy"]=0
f, ax = plt.subplots(figsize=(16, 8))
sns.tsplot(df, time='RankingDate', unit='Dummy', condition='Player', value='Points', ax=ax)