Pandas 如何绘制特定索引范围的两列?
我从一个有两列的.txt文件中创建了一个数据帧。我有一个特定的索引范围(3751:6252),我想为它绘制第1列(freq)和第2列(phase) 我该怎么做Pandas 如何绘制特定索引范围的两列?,pandas,dataframe,plot,indexing,Pandas,Dataframe,Plot,Indexing,我从一个有两列的.txt文件中创建了一个数据帧。我有一个特定的索引范围(3751:6252),我想为它绘制第1列(freq)和第2列(phase) 我该怎么做 import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns #open text file and save it as a df (dataframe) textfile = pd.read_csv("Raw
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
#open text file and save it as a df (dataframe)
textfile = pd.read_csv("RawPhaseData.txt", sep='\s+', skiprows= 2, header=None, names = ['freq', 'phase'])
#make the index equal to frequency
#textfile.set_index("freq", inplace=True)
p = textfile[3751:6252]
x = p['freq']
y = p['phase']
plt.plot(x,y)
plt.show()
需要一个图形,但没有输出
当我说打印时,部分结果(p)
当我说打印(x)时,部分结果
当我说打印(y)时,部分结果
..导入后,可能需要添加%matplotlib内联
将matplotlib.pyplot导入为plt
%matplotlib内联
freq phase
3751 0.55000000000000 -51.101839657065
3752 0.55004000000000 -51.251119837268
3753 0.55008000000000 -51.400516517531
3754 0.55012000000000 -51.550029980720
3755 0.55016000000000 -51.699660509792
3756 0.55020000000000 -51.849408387787
3751 0.55000000000000
3752 0.55004000000000
3753 0.55008000000000
3754 0.55012000000000
3755 0.55016000000000
3756 0.55020000000000
3757 0.55024000000000
3758 0.55028000000000
3759 0.55032000000000
3751 -51.101839657065
3752 -51.251119837268
3753 -51.400516517531
3754 -51.550029980720
3755 -51.699660509792
3756 -51.849408387787
3757 -51.999273897829