小编DBi*_*nJP的帖子

pandas resample文档

所以我完全理解如何使用resample,但文档并没有很好地解释选项.

所以resample函数中的大多数选项都很简单,除了这两个:

  • rule:表示目标转换的偏移字符串或对象
  • how:string,down-or-sampling的方法,默认为'mean'

因此,通过查看我在网上找到的尽可能多的示例,我可以看到规则,你可以做'D'一天,'xMin'几分钟,'xL'几毫秒,但这就是我能找到的.

对我怎么看到以下内容:'first',np.max,'last','mean',和'n1n2n3n4...nx'其中nx为每列索引的第一个字母.

那么在我缺少的文档中是否有某个地方显示了pandas.resample规则和输入的每个选项?如果是的话,因为我找不到它.如果不是,那么他们的选择是什么?

python documentation pandas

170
推荐指数
2
解决办法
10万
查看次数

如何将颜色条添加到极坐标图(玫瑰图)?

该示例中,颜色与每个条的半径相关.如何在这个情节中添加一个颜色条?

matplotlib的例子

我的代码模仿了"玫瑰图"投影,它基本上是极坐标投影的条形图.

这是它的一部分:

angle = radians(10.)
patches = radians(360.)/angle
theta = np.arange(0,radians(360.),angle)
count = [0]*patches
for i, item in enumerate(some_array_of_azimuth_directions):
    temp = int((item - item%angle)/angle)
    count[temp] += 1
width = angle * np.ones(patches)

# force square figure and square axes looks better for polar, IMO
fig = plt.figure(figsize=(8,8))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)

rmax = max(count) + 1

ax.set_rlim(0,rmax)
ax.set_theta_offset(np.pi/2)
ax.set_thetagrids(np.arange(0,360,10))
ax.set_theta_direction(-1)

# project strike distribution as histogram bars
bars = ax.bar(theta, count, width=width)
r_values = …
Run Code Online (Sandbox Code Playgroud)

python matplotlib colorbar rose-diagram

7
推荐指数
1
解决办法
3803
查看次数

DICOM"媒体存储SOP实例UID"="SOP实例UID"是真的吗?为什么?

我在阅读DICOM标准时有两个问题:

在DICOM文件中,(0002 0003)"媒体存储SOP实例UID"和(0008 0018)"SOP实例UID",它们是否相同?(0002 0002)和(0008 0016)怎么样?为什么?

dicom uid

7
推荐指数
2
解决办法
1547
查看次数

如何从R中的basename结尾删除文件扩展名?

如何列出文件夹中的数据文件并将其文件名不带扩展名作为数据帧中的因素存储?换句话说:如何从省略 '.csv' 扩展名的文件名列表创建字符向量,并在从这些文件创建数据帧后将此向量作为因子列表存储在数据帧中?

我的最终目标是将包含我的数据的文件名作为 StudyID 存储为数据帧中的因子。我认为这是一个非常简单的任务,但我还没有发现正则表达式所需的格式,或者 sapply 和 gsub 之间是否存在一些改变格式的交互。

'planned' 和 'blurred' 两个文件夹分别包含名为 1.csv、2.csv 等的文件,有时带有非连续数字。具体来说,我认为最好获取因子“模糊 1”、“计划 1”、“模糊 2”、“计划 2”等来命名从这些文件导入的数据以引用研究 ID(编号)和类别(计划的或模糊的)。

我在 RStudio 1.0.143 中尝试过的代码,对发生的事情进行了评论:

# Create a vector of the files to process
filenames <- list.files(path = '../Desktop/data/',full.names=TRUE,recursive=TRUE) 
# We parse the path to find the terminating filename which contains the StudyID.
FileEndings <- basename(filenames)
# We store this filename as the StudyID
regmatches('.csv',FileEndings,invert=TRUE) -> StudyID   # Error: ‘x’ and ‘m’ must have the same length
lapply(FileEndings,grep('.csv',invert=TRUE)) -> StudyID …
Run Code Online (Sandbox Code Playgroud)

regex csv r filepath gsub

1
推荐指数
1
解决办法
3813
查看次数

标签 统计

python ×2

colorbar ×1

csv ×1

dicom ×1

documentation ×1

filepath ×1

gsub ×1

matplotlib ×1

pandas ×1

r ×1

regex ×1

rose-diagram ×1

uid ×1