我在大熊猫中进行绘图,遇到了熊猫链操作的以下问题
import numpy as np
import pandas as pd
import seaborn as sns
n = 365
df = pd.DataFrame(data = {"A":np.random.randn(n), "B":np.random.randn(n)+1},
index=pd.date_range(start="2017-01-01", periods=n, freq="D"))
df1 = df.stack().reset_index().set_axis(['month','vars','vals'],axis=1,inplace=False).set_index('month',drop=True)
sns.boxplot(x=df1.index.month, y="vals", hue="vars", data=df1)
如何使用单个熊猫链操作来做到这一点?
我的尝试:(给出错误的图像输出)
(df.stack().reset_index().set_axis(['month','vars','vals'],axis=1,inplace=False)
.set_index('month',drop=False)
.pipe( (sns.boxplot, 'data'), x='month', y="vals", hue="vars"))
所需图片:
问题
如何在ONE-LINER中获得上述外观的图像?
答案 0 :(得分:1)
您想要使用lambda函数将数据帧传递给sns.boxplot吗?
function t31_before_shop_list_call() {
if ( is_user_logged_in()) {
$Conn = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
$itemCodesArray = array(); // WILL CONTAIN ARRAY OF SKU's FOR WS
while (have_posts()) : the_post();
global $product;
if( $product->is_type( 'simple' ) ){
$sku = get_post_meta( get_the_ID(), '_sku', true );
array_push($itemCodesArray, $sku);
} elseif( $product->is_type( 'variable' ) ){
$child_ids = $product->get_children();
foreach ($child_ids as $child_id) {
$sku = get_post_meta( $child_id, '_sku', true );
array_push($itemCodesArray, $sku);
}
}
endwhile;
... RUN WEBSERVICE THAT GETS CLIENTS PRICES FOR THE
... RUN THROUGH EACH PRODUCT RETURNED IN WEBSERVICE AND EXEC FOLLOWING UPDATE
UPDATE wp_postmeta
SET meta_value = " . $GDUSproduct_price . "
WHERE post_id = " . $GDUSproduct_id . "
AND meta_key = '_regular_price';";
DELETE
FROM `wp_options`
WHERE (`option_name` LIKE '_transient_wc_var_prices_%'
OR option_name` LIKE '_transient_timeout_wc_var_prices_%')";
}
}
add_action( 'woocommerce_before_shop_loop', 't31_before_shop_list_call', 15 );