我想在带有NaN
的数据框中生成包括np.random.randn
的随机浮点数
答案 0 :(得分:2)
您可以生成一个随机浮点数组,然后使用np.choice
和p
创建一个掩码,以允许您设置要包含的NaN
数的权重。
类似的东西:
import numpy as np
a = np.random.randn(20)
mask = np.random.choice([1, 0], a.shape, p=[.1, .9]).astype(bool)
a[mask] = np.nan
结果:
array([ 1.2769248 , 0.5949608 , -1.38006737, 0.3582266 , -1.852884 ,
0.81121663, -1.45830948, 0.03117856, 0.54509948, 1.22019729,
1.71643753, nan, -0.32470862, -0.77604474, 0.76698089,
-0.47863251, nan, -0.33308071, -0.32026717, 1.8493752 ])
答案 1 :(得分:0)
如果您正在使用DataFrame,则可以使用 var channelData = context.Activity.GetChannelData<TeamsChannelData>();
var message = Activity.CreateMessageActivity();
message.Text = "Hello World";
var conversationParameters = new ConversationParameters
{
IsGroup = true,
ChannelData = new TeamsChannelData
{
Channel = new ChannelInfo(channelData.Channel.Id),
},
Activity = (Activity) message
};
var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl));
var response = await
connectorClient.Conversations.CreateConversationAsync(conversationParameters);
。
MicrosoftAppCredentials.TrustServiceUrl(serviceUrl, DateTime.MaxValue);
var connectorClient = new ConnectorClient(new Uri(serviceUrl));