我正在尝试使用Python在csv excel文件中绘制两个独立列的折线图。该文件包含有关2016年上映电影的5列详细信息,这些列是:电影标题/发行日期/发行商/类型/ MPAA /售出的门票。
在这种特定情况下,我试图以折线图的形式绘制发行日期和售票数量,然后找出哪个月售票率最高。 Here's some of the dataframe of the CSV file.这是我到目前为止的内容,但是我不确定从这里开始应该去哪里,而且我还会遇到很多错误。如果有人可以帮助我,我将不胜感激。
import pandas as pd
from datetime import datetime
import csv
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
headers = ['Tickets Sold','Release Date']
df = pd.read_csv('2016_movie_data.csv',names=headers)
print (df)
df['Release Date'] = df['Release Date'].map(lambda x: datetime.strptime(str(x), '%Y/%m/%d %H:%M:%S.%f'))
x = df['Release Date']
y = df['Tickets Sold']
# plot
plt.plot(x,y)
# beautify the x-labels
plt.gcf().autofmt_xdate()
plt.show()
答案 0 :(得分:0)
尝试导入 matplotlib.pyplot.plot 并使用以下命令:
import 'package:flutter/material.dart';
void showWarningSnackBar(BuildContext context, String message) {
// Find the Scaffold in the widget tree and use it to show a SnackBar.
ScaffoldFeatureController<Widget, dynamic> _scaffold;
// Find the Scaffold in the widget tree and use it to show a SnackBar.
_scaffold = Scaffold.of(context).showSnackBar(SnackBar(
content: InkWell(
onTap: () {
_scaffold.close();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
AppImage.asset(
assetName: YOUR_IMAGE_NAME,
fit: BoxFit.contain,
width: 20,
color: COLOR),
const SizedBox(
width: 10,
),
Text(
'$message',
maxLines: 2,
),
],
),
),
duration: const Duration(seconds: 10),
backgroundColor: COLOR,
));
}
通过编辑最后三行代码